<!DOCTYPE html>
<html  lang="en">
<head>
    <meta charset="utf-8">
<title>noback</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />



    <meta property="og:type" content="website">
<meta property="og:title" content="noback">
<meta property="og:url" content="http://alpaca-h.gitee.io/index.html">
<meta property="og:site_name" content="noback">
<meta property="og:locale" content="en_US">
<meta property="og:image" content="http://alpaca-h.gitee.io/images/og_image.png">
<meta property="article:author" content="Alpaca">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="http://alpaca-h.gitee.io/images/og_image.png">







<link rel="icon" href="/images/favicon.svg">


<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.7.2/css/bulma.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.4.1/css/all.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Ubuntu:400,600|Source+Code+Pro">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/highlight.js@9.12.0/styles/androidstudio.css">


    
    
    
    <style>body>.footer,body>.navbar,body>.section{opacity:0}</style>
    

    
    
    
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/lightgallery@1.6.8/dist/css/lightgallery.min.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/justifiedGallery@3.7.0/dist/css/justifiedGallery.min.css">
    

    
    

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/outdatedbrowser@1.1.5/outdatedbrowser/outdatedbrowser.min.css">


    
    
    
    

<link rel="stylesheet" href="/css/back-to-top.css">


    
    

    
    
    
    

    
    
<link rel="stylesheet" href="/css/progressbar.css">
<script src="https://cdn.jsdelivr.net/npm/pace-js@1.0.2/pace.min.js"></script>

    
    
    

    
    
    
        <script async="" src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    

    


<link rel="stylesheet" href="/css/style.css">
<meta name="generator" content="Hexo 4.2.0"><link rel="alternate" href="/atom.xml" title="noback" type="application/atom+xml">
</head>
<body class="is-3-column">
    <nav class="navbar navbar-main">
    <div class="container">
        <div class="navbar-brand is-flex-center">
            <a class="navbar-item navbar-logo" href="/">
            
                <img src="/images/logo.svg" alt="noback" height="28">
            
            </a>
        </div>
        <div class="navbar-menu">
            
            <div class="navbar-start">
                
                <a class="navbar-item is-active"
                href="/">Home</a>
                
                <a class="navbar-item"
                href="/archives/">Archives</a>
                
                <a class="navbar-item"
                href="/categories/">Categories</a>
                
                <a class="navbar-item"
                href="/tags/">Tags</a>
                
                <a class="navbar-item"
                href="/about/">About</a>
                
            </div>
            
            <div class="navbar-end">
                
                    
                    
                    <a class="navbar-item" target="_blank" title="AlphaLxy GitHub" href="https://www.github.com/AlphaLxy">
                        
                        <i class="fab fa-github"></i>
                        
                    </a>
                    
                
                
                
                <a class="navbar-item search" title="Search" href="javascript:;">
                    <i class="fas fa-search"></i>
                </a>
                
            </div>
        </div>
    </div>
</nav>
    
    <section class="section">
        <div class="container">
            <div class="columns">
                <div class="column is-8-tablet is-8-desktop is-6-widescreen has-order-2 column-main">
    <div class="card">
    
    <div class="card-content article ">
        <h1 class="title is-size-3 is-size-4-mobile has-text-weight-normal">
            
                <a class="has-link-black-ter" href="/2020/01/05/blog_back_new/linux/keepalive+lvs%E5%9B%9B%E5%B1%82%E8%B4%9F%E8%BD%BD%E5%9D%87%E8%A1%A1/"><i class="fas fa-angle-double-right"></i>keepalive+lvs 四层负载均衡</a>
            
        </h1>
        
        <div class="level article-meta is-size-7 is-uppercase is-mobile is-overflow-x-auto">
            <div class="level-left">
                <time class="level-item has-text-grey" datetime="2020-01-05T05:06:09.000Z"><i class="far fa-calendar-alt">&nbsp;</i>2020-01-05</time>
                
                <time class="level-item has-text-grey is-hidden-mobile" datetime="2020-01-07T03:42:42.162Z"><i class="far fa-calendar-check">&nbsp;</i>2020-01-07</time>
                
                
                <div class="level-item">
                <i class="far fa-folder-open has-text-grey"></i>&nbsp;
                <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a>&nbsp;/&nbsp;<a class="has-link-grey -link" href="/categories/blog-back-new/linux/">linux</a>
                </div>
                
                
                <span class="level-item has-text-grey">
                    <i class="far fa-clock"></i>&nbsp;
                    
                    
                    22 minutes read (About 3304 words)
                </span>
                
                
            </div>
        </div>
        
        <div class="content">
            <h2 id="关键词"><a href="#关键词" class="headerlink" title="关键词"></a>关键词</h2><p>LB (Load Balancer 负载均衡)<br>HA (High Available 高可用)<br>Failover (失败切换)<br>Cluster (集群)<br>LVS (Linux Virtual Server Linux 虚拟服务器)<br>DS (Director Server)，指的是前端负载均衡器节点<br>RS (Real Server)，后端真实的工作服务器<br>VIP (Virtual IP)，虚拟的 IP 地址，向外部直接面向用户请求，作为用户请求的目标的 IP 地址<br>DIP (Director IP)，主要用于和内部主机通讯的 IP 地址<br>RIP (Real Server IP)，后端服务器的 IP 地址<br>CIP (Client IP)，访问客户端的 IP 地址</p>
        </div>
        
        
        
        <hr style="height:1px;margin:1rem 0"/>
        <div class="level is-mobile is-flex">
            <div class="level-start">
                
            </div>
            <div class="level-start">
                <div class="level-item">
                <a class="button is-size-7 is-light" href="/2020/01/05/blog_back_new/linux/keepalive+lvs%E5%9B%9B%E5%B1%82%E8%B4%9F%E8%BD%BD%E5%9D%87%E8%A1%A1/#more"><i class="fas fa-book-reader has-text-grey"></i>&nbsp;&nbsp;Read More</a>
                </div>
            </div>
        </div>
        
        
    </div>
</div>









    <div class="card">
    
    <div class="card-content article ">
        <h1 class="title is-size-3 is-size-4-mobile has-text-weight-normal">
            
                <a class="has-link-black-ter" href="/2020/01/05/blog_back_new/linux/linux%E7%BD%91%E7%BB%9C%E7%AE%A1%E7%90%86/iptables%E3%80%81firewall%E9%98%B2%E7%81%AB%E5%A2%99/"><i class="fas fa-angle-double-right"></i>iptables、firewall 防火墙</a>
            
        </h1>
        
        <div class="level article-meta is-size-7 is-uppercase is-mobile is-overflow-x-auto">
            <div class="level-left">
                <time class="level-item has-text-grey" datetime="2020-01-05T04:03:16.000Z"><i class="far fa-calendar-alt">&nbsp;</i>2020-01-05</time>
                
                <time class="level-item has-text-grey is-hidden-mobile" datetime="2020-01-06T03:17:25.428Z"><i class="far fa-calendar-check">&nbsp;</i>2020-01-06</time>
                
                
                <div class="level-item">
                <i class="far fa-folder-open has-text-grey"></i>&nbsp;
                <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a>&nbsp;/&nbsp;<a class="has-link-grey -link" href="/categories/blog-back-new/linux/">linux</a>
                </div>
                
                
                <span class="level-item has-text-grey">
                    <i class="far fa-clock"></i>&nbsp;
                    
                    
                    a few seconds read (About 99 words)
                </span>
                
                
            </div>
        </div>
        
        <div class="content">
            <h2 id="iptables、firewall防火墙"><a href="#iptables、firewall防火墙" class="headerlink" title="iptables、firewall防火墙"></a>iptables、firewall防火墙</h2><h2 id="防火墙错误导致的原因"><a href="#防火墙错误导致的原因" class="headerlink" title="防火墙错误导致的原因"></a>防火墙错误导致的原因</h2><ol>
<li>开通httpd后，当前机器下使用curl可访问，但外部机器访问ip+端口则无法访问<pre><code class="bash">[root@localhost ~]# curl http://10.0.5.92:8888
curl: (7) Failed connect to 10.0.5.92:8888; No route to host</code></pre>
curl报如下错误：curl: (7) Failed connect to 172.16.225.43:7001; No route to host</li>
</ol>
<p>解决办法<br>—-&gt; 在被访问机器下开放8888端口<br>—-&gt; iptables -l INPUT -p tcp –dport 8888 -j ACCEPT</p>

        </div>
        
        
        
        
    </div>
</div>









    <div class="card">
    
    <div class="card-content article ">
        <h1 class="title is-size-3 is-size-4-mobile has-text-weight-normal">
            
                <a class="has-link-black-ter" href="/2020/01/05/blog_back_new/linux/linux%E7%BD%91%E7%BB%9C%E7%AE%A1%E7%90%86/netstat/"><i class="fas fa-angle-double-right"></i>netstat</a>
            
        </h1>
        
        <div class="level article-meta is-size-7 is-uppercase is-mobile is-overflow-x-auto">
            <div class="level-left">
                <time class="level-item has-text-grey" datetime="2020-01-05T03:51:48.000Z"><i class="far fa-calendar-alt">&nbsp;</i>2020-01-05</time>
                
                <time class="level-item has-text-grey is-hidden-mobile" datetime="2020-01-06T03:17:25.428Z"><i class="far fa-calendar-check">&nbsp;</i>2020-01-06</time>
                
                
                <div class="level-item">
                <i class="far fa-folder-open has-text-grey"></i>&nbsp;
                <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a>&nbsp;/&nbsp;<a class="has-link-grey -link" href="/categories/blog-back-new/linux/">linux</a>
                </div>
                
                
                <span class="level-item has-text-grey">
                    <i class="far fa-clock"></i>&nbsp;
                    
                    
                    2 minutes read (About 328 words)
                </span>
                
                
            </div>
        </div>
        
        <div class="content">
            <h2 id="netstat工具"><a href="#netstat工具" class="headerlink" title="netstat工具"></a>netstat工具</h2><p>netstat是在内核中访问网络相关信息的程序。</p>
<ol>
<li>提供TCP连接、TCP和UDP监听、进程内存管理的状态。</li>
<li>监控TCP/IP网络的非常有用的工具，显示路由表、实际网络连接以及每一个网络接口设备的状态信息。</li>
<li>使用netstat可以让用户知道有哪些网络连接正在运作，使用时如果不带参数，netstat显示活动的TCP连接</li>
</ol>
<pre><code class="bash"># 安装
yum install net-tools
# 使用
netstat 选项：
常用参数：
-a:显示所有的socket，包括监听的以及未监听的。
-n:不使用域名和服务名，而使用IP和端口号。
-l:仅列出在listen状态的网络服务。
-p:显示建立连接的程序名和PID。
-e:显示以太网统计。
-s:显示每个协议的统计。
-t：显示TCP协议连接情况。
-u:显示UDP协议连接情况。
-c:每隔一个固定时间，执行netstat命令。
-r：显示核心路由表。
-i:显示所有的网络接口信息&lt;&gt; </code></pre>
<h3 id="常用指令"><a href="#常用指令" class="headerlink" title="常用指令"></a>常用指令</h3><pre><code class="bash"># 显示建立连接的程序名 PID IP 端口以及监听状态
[root@localhost ~]# netstat -pan | grep 8888
tcp6       0      0 :::8888                 :::*                    LISTEN      16711/httpd </code></pre>

        </div>
        
        
        
        
    </div>
</div>









    <div class="card">
    
    <div class="card-content article ">
        <h1 class="title is-size-3 is-size-4-mobile has-text-weight-normal">
            
                <a class="has-link-black-ter" href="/2020/01/04/blog_back_new/%E7%BD%91%E7%BB%9C/%E7%BD%91%E7%BB%9C%E9%83%A8%E7%BD%B2%E9%9C%80%E6%B1%82%E5%88%86%E6%9E%90/"><i class="fas fa-angle-double-right"></i>网络部署需求分析</a>
            
        </h1>
        
        <div class="level article-meta is-size-7 is-uppercase is-mobile is-overflow-x-auto">
            <div class="level-left">
                <time class="level-item has-text-grey" datetime="2020-01-04T02:22:09.000Z"><i class="far fa-calendar-alt">&nbsp;</i>2020-01-04</time>
                
                <time class="level-item has-text-grey is-hidden-mobile" datetime="2020-01-07T03:28:19.515Z"><i class="far fa-calendar-check">&nbsp;</i>2020-01-07</time>
                
                
                <div class="level-item">
                <i class="far fa-folder-open has-text-grey"></i>&nbsp;
                <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a>&nbsp;/&nbsp;<a class="has-link-grey -link" href="/categories/blog-back-new/%E7%BD%91%E7%BB%9C/">网络</a>
                </div>
                
                
                <span class="level-item has-text-grey">
                    <i class="far fa-clock"></i>&nbsp;
                    
                    
                    12 minutes read (About 1751 words)
                </span>
                
                
            </div>
        </div>
        
        <div class="content">
            <h1 id="网络部署需求分析"><a href="#网络部署需求分析" class="headerlink" title="网络部署需求分析"></a>网络部署需求分析</h1><p>后面需要根据tower给出的内容对网络环境，机器上架规划内容<br>由于tower中给出的大部分都是纸上信息，这里做几个例子进行一下总结</p>
<p><font color='blue'>凡是没有提到2层或者3层需求的，都按照3层需求来处理</font></p>
<h2 id="自动生成汇聚端口配置"><a href="#自动生成汇聚端口配置" class="headerlink" title="自动生成汇聚端口配置"></a>自动生成汇聚端口配置</h2><pre><code class="py">import os
import json

# 指定端口类型  有些做过堆叠的交换机 MemberID是不同的
port_type = &quot;1&quot;

for i in range(1,16):
    print(&quot;interface bridge-aggregation %s&quot;%i)
    print(&quot;interface GigabitEthernet%s/0/%s&quot;%(port_type,int(i*2-1)))
    print(&quot;port link-aggregation group %s&quot;%i)
    print(&quot;interface GigabitEthernet%s/0/%s&quot;%(port_type,int(i*2)))
    print(&quot;port link-aggregation group %s&quot;%i)


## REANME.md
##交换机的配置需要批量配置管理端口
##用这个脚本生成就ok了</code></pre>
<h2 id="基础配置"><a href="#基础配置" class="headerlink" title="*****基础配置"></a>*****基础配置</h2><p>基础配置 二三层通用</p>
<pre><code class="bash"># 用户配置
local-user admin class manage
 service-type ssh
 authorization-attribute user-role level-3
 authorization-attribute user-role network-admin
 authorization-attribute user-role network-operator
#
local-user root class manage
 service-type ssh
 authorization-attribute user-role level-3
 authorization-attribute user-role network-admin
 authorization-attribute user-role network-operator

user-interface vty 0 4
authentication-mode scheme       
 user-role network-admin
protocol inbound all
quit

# 不显示版本信息
undo copyright-info enable

# 公钥导入
public-key peer pub
  public-key-code begin    
   30820122300D06092A864886F70D01010105000382010F003082010A0282010100D37D67EC
   5A9466CD38895097E74386EBBEFA9EC59236DF5E96D7514B2903C21F09C6D47D74792B5E3D
   C1F99DB4D43614AE3AD61DEFFAF35CED9B94DBD85DE174598C491FA043F8C700DA686BFFCA
   227E4E7417A251CD7590673B4C1A227962F65CBA6017329479484EF8FE48A8E2FED636C846
   5765801A0D62C821906FF8E7188DA69D716FD392E8C0D4D0618E9020670FFA24CF083E2EF7
   690EABCA43AA4341D798A72B6FFB5A0A1BEF0F4B14B6B66E5F7126582BD11A11F4220EA3FF
   C1A5DF36E86E76A8EF6A97949158F094CBAD09725069A090CBA36D95CB6A9531A5AB8B3ED5
   8D6C63C8138320F0F1ECD7B25203A1B79FC82635B0F53475BC428B3B741F0203010001
  public-key-code end
 peer-public-key end


public-key peer upyun
 public-key-code begin
   30820122300D06092A864886F70D01010105000382010F003082010A0282010100BEF4DB4E
   5224F5FFE95AF67CC1753592979F6C1379E0A1FB8519C0E6E626B50F221957806B64384173
   F2B370254381D583D3EC70D4211CC599CF6C1615754E985895D1E78E1E62788A9BC2E4D2EB
   55A18FD20D2B692813114C650FE4FC883DB5467039264C2478332C2C967F3DAE83AFBDFAB3
   D794F38DCB2E112184127A151741947DFBB00E8E66B9037131C54A27DE703B2E80A3D8D3C6
   79CFC9E851D9C76610228790D7E2253D7E7735481D2EA61AA71D6DFD2EAC037203CE08943E
   43DF88AC1ECCB77433358B5ABDF080616D6B6C40AEBEEEDD64D8B8718F091CAA0EA8D5A6A0
   2B6106D931E45717C94DBC0F3FF6608CB609C4DA4860C8C48EE67CB304470203010001
 public-key-code end
 peer-public-key end
# 用户公钥认证
ssh user admin service-type stelnet authentication-type publickey assign publickey pub
ssh user root service-type stelnet authentication-type publickey assign publickey upyun

# acl过滤
acl number 2000
description Login IP Control
rule 1 permit source 192.168.0.0 0.0.255.255
rule 5 permit source 115.238.93.82 0
rule 10 permit source 115.231.100.64 0.0.0.63
rule 15 permit source 121.52.226.192 0.0.0.63
rule 20 permit source 115.238.54.160 0.0.0.15
rule 25 permit source 124.160.114.192 0.0.0.15
rule 30 permit source 106.186.117.158 0.0.0.255
rule 35 permit source 157.119.232.0  0.0.0.31
rule 40 permit source 218.205.64.19 0.0.0.31
rule 45 permit source 112.17.251.0 0.0.0.31
rule 50 permit source 121.52.250.193 0.0.0.31
rule 55 permit source 183.131.0.65 0.0.0.31
rule 60 permit source 43.230.89.160 0.0.0.31
rule 65 permit source 111.1.32.0 0.0.0.127
rule 70 permit source 115.231.97.0 0.0.0.31
rule 1000 deny source any

quit
undo ip http enable

# ssh过滤
ssh server enable
ssh server acl 2000

# 接口过滤
user-interface vty 0 4
acl 2000 inbound

# snmp监控
snmp-agent
snmp-agent local-engineid 800063A203
snmp-agent community read hgE6ofdZ3b
snmp-agent sys-info version v2c v3 

# 机器时间同步
ntp-service unicast-server 218.189.210.4 source Vlan-interface 1
ntp-service unicast-server 137.189.4.10 source Vlan-interface 1
clock timezone beijing add 8

# 路由追踪
ip ttl-expires enable
ip unreachables enable
ipv6 unreachables enable</code></pre>
<h2 id="二层环路检测配置"><a href="#二层环路检测配置" class="headerlink" title="***二层环路检测配置"></a>***二层环路检测配置</h2><p>h3c 5130配置</p>
<pre><code class="bash">loopback-detection global enable vlan all
# 端口定时器
shutdown-interval 120 
# 环路检测报文发送周期
loopback-detection interval-time 5

# 接口内部配置
# 环路检测接口配置
loopback-detection action shutdown
loopback-detection enable vlan all</code></pre>
<p>h3c 5120配置</p>
<pre><code class="bash">loopback-detection multi-port-mode enable
loopback-detection enable
# 端口定时器
shutdown-interval 120 
# 环路检测报文发送周期
loopback-description interval-time 5
# 环路检测接口配置
loopback-detection action shutdown
loopback-detection enable vlan all</code></pre>
<h2 id="走二层与走三层的关系"><a href="#走二层与走三层的关系" class="headerlink" title="走二层与走三层的关系"></a>走二层与走三层的关系</h2><p>交换机的二三层决定取决于OSI模型 ，二层走数据链路层 三层在二层基础上添加网络层<br>另外交换机是否走三层，应该取决于网络的规划</p>
<p><font color='blue'>首先是二层</font><br>交换机走二层，路由在核心交换机上，不转发多网段的数据(Vlan)<br>数据走数据链路层<br>以上说明二层交换机不能跨网段传输信息，在划分vlan的情况下，只能走同vlan下的数据</p>
<p><font color='red'>需要测试</font></p>
<pre><code class="bash"># 在同vlan下，不通网段ip需要默认路由？

# 在同vlan下，同网段ip不需要默认路由？  

# 静态路由的功能除了 规定流量转发还有什么？</code></pre>
<p>静态路由指向核心交换机上的网关</p>
<p><font color='blue'>其次是三层交换机</font><br>三层交换机就是在二层交换机的基础上加了路由功能，交换机走三层，路由在当前三层交换机上<br>三层交换机能转发多网段的数据,路由器转发数据是基于IP地址进行转发的！！而二层交换机是基于MAC地址转发的！！<br>让基于MAC地址转发的交换机实现基于IP地址转发  ===&gt; 三层交换机</p>
<p>三层交换机可以转发多网段的数据，不局限于同vlan下的数据转发，</p>
<p>静态路由指向网关</p>
<p>虽然三层交换机有路由功能，但不能完全取代路由器，基础原理不同</p>
<h3 id="二层架构于三层架构的区别"><a href="#二层架构于三层架构的区别" class="headerlink" title="二层架构于三层架构的区别"></a>二层架构于三层架构的区别</h3><p><a href="https://blog.51cto.com/fenggao/1582958" target="_blank" rel="noopener">https://blog.51cto.com/fenggao/1582958</a><br><a href="https://www.cnblogs.com/sunada2005/articles/2666902.html" target="_blank" rel="noopener">https://www.cnblogs.com/sunada2005/articles/2666902.html</a></p>
<h3 id="举例"><a href="#举例" class="headerlink" title="举例"></a>举例</h3><p>比如你现在有两台交换机 A  B<br>A 作为核心交换机<br>B 作为核心机下面的机器</p>
<p>要走二层的话，则同vlan走个静态就ok了</p>
<p>要走三层的话，也就是说B下面有多个网段的机器 两台机器的vlan是不需要相同的，三层交换机会动态配置</p>
<h2 id="福建厦门联通"><a href="#福建厦门联通" class="headerlink" title="福建厦门联通"></a>福建厦门联通</h2><p>CUN-FJ-XMN-S01<br><img src="http://img.noback.top/2020-01-02-11-23-28.png" alt="2020-01-02-11-23-28"><br>如图以上信息</p>
<pre><code class="bash">ip信息  36.248.208.224/27
机器信息 15台1U服务器  1台5130交换机(52口)  2个万兆多模  30根网线 16根电源线

--&gt;
--&gt;
--&gt;
也就是说 15台服务器每台2根网线  5130交换机前面30个电口做汇聚
interface bridge-aggregation 1
interface GigabitEthernet1/0/1
port link-aggregation group 1
interface GigabitEthernet1/0/2
port link-aggregation group 1
# 可以用脚本生成
两个万兆多模，交换机上联接入一个，上联一个</code></pre>
<h2 id="走二层"><a href="#走二层" class="headerlink" title="****走二层"></a>****走二层</h2><h3 id="不走vlan1-指定vlan-2250"><a href="#不走vlan1-指定vlan-2250" class="headerlink" title="不走vlan1 指定vlan 2250"></a>不走vlan1 指定vlan 2250</h3><pre><code class="bash"># 配置vlan2250
vlan 2250
int vlan-interface 2250
ip address 36.248.208.226 255.255.255.224
# 端口汇聚
interface bridge-aggregation 1
interface GigabitEthernet2/0/1
port link-aggregation group 1
interface GigabitEthernet2/0/2
port link-aggregation group 1
...
int range Bridge-Aggregation 1 to Bridge-Aggregation 15
port access vlan 2250
# 配置上联口
interface ten1/0/49
port link-type trunk # 接入trunk模式，对应trunk模式
undo port trunk permit vlan 1
port trunk permit vlan 2250
# 关闭端口stp生成树功能
int range g1/0/1 to g1/0/30 
undo stp enable

# 二层环路检测配置</code></pre>
<h2 id="四川成都联通"><a href="#四川成都联通" class="headerlink" title="四川成都联通"></a>四川成都联通</h2><p>CMN-SC-CTU4-S01<br><img src="http://img.noback.top/2020-01-02-11-24-20.png" alt="2020-01-02-11-24-20"><br>ZA-16030782    1 2 口<br>ZA-16030781    3 4 口<br>ZA-16031259    5 6 口<br>ZA-16031257    7 8 口<br>ZA-16030285    9 10 口<br>ZA-15041213    11 12 口<br>ZA-15041819    13 14 口<br>ZA-15041852    15 16 口<br>ZA-15070367    17 18 口<br>ZA-19010018    19 20 口</p>
<p>6300   47 48上联口</p>
<pre><code class="bash"># 走三层
10 台交换机 汇聚 走1-20口
 走47 48口 # 这个需要问，图里没给</code></pre>
<h3 id="走三层"><a href="#走三层" class="headerlink" title="*****走三层"></a>*****走三层</h3><pre><code class="bash"># 基础配置 复制粘贴
# 配置vlan 200 201
vlan 200
int vlan-interface 200
ip address 117.172.4.50 255.255.255.252
vlan 201 
int vlan-interface 201
ip address 117.172.4.54 255.255.255.252
vlan 1
int vlan-interface 1
ip address 117.172.22.129 255.255.255.224

# 配置静态路由
ip route-static 0.0.0.0 0 117.172.4.49
ip route-static 0.0.0.0 0 117.172.4.53

# 配置上联
int ten 1/0/47
port access vlan 200
int ten 1/0/49
port access vlan 201

# 二层环路检测配置</code></pre>

        </div>
        
        
        
        
    </div>
</div>









    <div class="card">
    
    <div class="card-content article ">
        <h1 class="title is-size-3 is-size-4-mobile has-text-weight-normal">
            
                <a class="has-link-black-ter" href="/2020/01/03/blog_back_new/linux/httpd%E6%9C%8D%E5%8A%A1/"><i class="fas fa-angle-double-right"></i>httpd服务</a>
            
        </h1>
        
        <div class="level article-meta is-size-7 is-uppercase is-mobile is-overflow-x-auto">
            <div class="level-left">
                <time class="level-item has-text-grey" datetime="2020-01-03T09:18:50.000Z"><i class="far fa-calendar-alt">&nbsp;</i>2020-01-03</time>
                
                <time class="level-item has-text-grey is-hidden-mobile" datetime="2020-01-05T05:09:20.328Z"><i class="far fa-calendar-check">&nbsp;</i>2020-01-05</time>
                
                
                <div class="level-item">
                <i class="far fa-folder-open has-text-grey"></i>&nbsp;
                <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a>&nbsp;/&nbsp;<a class="has-link-grey -link" href="/categories/blog-back-new/linux/">linux</a>
                </div>
                
                
                <span class="level-item has-text-grey">
                    <i class="far fa-clock"></i>&nbsp;
                    
                    
                    5 minutes read (About 741 words)
                </span>
                
                
            </div>
        </div>
        
        <div class="content">
            <h2 id="apache-http-server"><a href="#apache-http-server" class="headerlink" title="apache http server"></a>apache http server</h2><p>Apache HTTP Server（简称Apache）是Apache软件基金会的一个开放源码的网页服务器，可以在大多数计算机操作系统中运行，由于其多平台和安全性被广泛使用，是最流行的Web服务器端软件之一。它快速、可靠并且可通过简单的API扩展，将Perl/Python等解释器编译到服务器中。</p>
<p><font color='blue'>  在Apache中，其配置文件目录为“/etc/httpd/conf/httpd.conf”，这里面包括设置网站资源的存放目录及一些相关的配置。</font></p>
<pre><code class="bash"># 安装http
yum install httpd 
# 开启服务
systemctl start httpd
# 检查httpd服务状态
systemctl status httpd
# 查看端口状态 netstat -anutp | grep  80</code></pre>
<h3 id="目录介绍"><a href="#目录介绍" class="headerlink" title="目录介绍"></a>目录介绍</h3><p>配置文件目录为“/etc/httpd/conf/httpd.conf”</p>
<pre><code class="bash">[root@localhost httpd]# ls -1
conf  # 存放服务的主配置文件
conf.d # 存放apache的主页信息
conf.modules.d
logs
modules
run</code></pre>
<h3 id="配置信息"><a href="#配置信息" class="headerlink" title="配置信息"></a>配置信息</h3><p>配置文件目录为“/etc/httpd/conf/httpd.conf”</p>
<pre><code class="bash">[root@localhost httpd]# vi /etc/httpd/conf/httpd.conf
ServerRoot &quot;/etc/httpd&quot;  #apache配置文件的根目录
Timeout 60  #超时时间，即连接服务端在60秒内没有任何操作，即自动断开
Listen 80   #监听的端口
ServerAdmin root@localhost  #设置管理员，e-mail 地址
ServerName www.example.com:80  #服务器主机名.

DocumentRoot &quot;/var/www/html&quot;   #网站页面根目录,存放文档的地方
&lt;Directory &quot;/var/www/html&quot;&gt; 
Options Indexes FollowSymLinks #O目录浏览 #Followsymlinks:可以用连接，要是想要禁止显示文件目录，可以直接在‘indexes’前加‘-’。
    AllowOverride None
    Order allow,deny #目录与访问的控制
    Allow from all 
&lt;/Directory&gt;

# 别名
Alias /icons/ &quot;/var/www/icons/&quot; #别名和别名目录
&lt;Directory &quot;/var/www/icons&quot;&gt;
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
&lt;/Directory&gt;

# 默认页面
&lt;/Directory&gt; Options Indexes  #当一个目录没有默认首页时，允许显示此目录列表
&lt;Directory /&gt;
    Options FollowSymLinks
    AllowOverride None
&lt;/Directory&gt;
--
DirectoryIndex index.html index.html.var #指定默认首页
AddDefaultCharset UTF-8   #设置服务器的默认编码为： UTF-8</code></pre>
<h2 id="python3构建http服务"><a href="#python3构建http服务" class="headerlink" title="python3构建http服务"></a>python3构建http服务</h2><pre><code class="bash">python3 -m http.server </code></pre>
<h2 id="维护-amp-错误"><a href="#维护-amp-错误" class="headerlink" title="维护&amp;错误"></a>维护&amp;错误</h2><h3 id="http服务已开启，但是无法访问网站"><a href="#http服务已开启，但是无法访问网站" class="headerlink" title="http服务已开启，但是无法访问网站"></a>http服务已开启，但是无法访问网站</h3><ol>
<li>在本地查看httpd服务<pre><code class="bash">curl http://localhost:80  </code></pre>
</li>
<li>看端口，如果是在公司内部，查看是否有部分ip端口被封 比如80 8080 88 等等<br>如果是以上情况，修改httpd 配置文件中的监听端口，重启http服务即可</li>
<li>永久关闭selinux ,需要重启<pre><code class="bash">vi /etc/selinux/config
SELINUX=disabled</code></pre>
</li>
<li>临时关闭<pre><code class="bash">setenforce 0 </code></pre>
</li>
</ol>
<p>可能会出现的报错信息<br>(13)Permission denied: make_sock: could not bind to address [::]:88<br>—-&gt; 关闭selinux即可</p>
<h3 id="检测端口是否被开启"><a href="#检测端口是否被开启" class="headerlink" title="检测端口是否被开启"></a>检测端口是否被开启</h3><p>使用telnet登陆的方式测试服务器端口是否开放</p>
<pre><code class="bash"># 未开放状态下的返回情况
➜  ~ telnet 10.0.5.92 8888
Trying 10.0.5.92...
telnet: Unable to connect to remote host: Connection refused

# 开放状态下的返回情况
➜  ~ telnet 10.0.5.91 8888
Trying 10.0.5.91...
Connected to 10.0.5.91.
Escape character is &#39;^]&#39;.</code></pre>
<h3 id="开放端口"><a href="#开放端口" class="headerlink" title="开放端口"></a>开放端口</h3><p>端口未被开放<br>———&gt; iptables -I INPUT -p tcp –dport 8888 -j ACCEPT</p>
<h2 id="地址"><a href="#地址" class="headerlink" title="地址"></a>地址</h2><p><a href="https://www.linuxidc.com/Linux/2017-05/143468.htm" target="_blank" rel="noopener">https://www.linuxidc.com/Linux/2017-05/143468.htm</a></p>

        </div>
        
        
        
        
    </div>
</div>









    <div class="card">
    
    <div class="card-content article ">
        <h1 class="title is-size-3 is-size-4-mobile has-text-weight-normal">
            
                <a class="has-link-black-ter" href="/2020/01/03/blog_back_new/%E7%BD%91%E7%BB%9C/%E4%BA%A4%E6%8D%A2%E6%9C%BA%E6%A3%80%E6%B5%8B%E4%BF%A1%E6%81%AF/"><i class="fas fa-angle-double-right"></i>交换机检测命令</a>
            
        </h1>
        
        <div class="level article-meta is-size-7 is-uppercase is-mobile is-overflow-x-auto">
            <div class="level-left">
                <time class="level-item has-text-grey" datetime="2020-01-03T03:14:42.000Z"><i class="far fa-calendar-alt">&nbsp;</i>2020-01-03</time>
                
                <time class="level-item has-text-grey is-hidden-mobile" datetime="2020-01-04T00:30:09.732Z"><i class="far fa-calendar-check">&nbsp;</i>2020-01-04</time>
                
                
                <div class="level-item">
                <i class="far fa-folder-open has-text-grey"></i>&nbsp;
                <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a>&nbsp;/&nbsp;<a class="has-link-grey -link" href="/categories/blog-back-new/%E7%BD%91%E7%BB%9C/">网络</a>
                </div>
                
                
                <span class="level-item has-text-grey">
                    <i class="far fa-clock"></i>&nbsp;
                    
                    
                    7 minutes read (About 1037 words)
                </span>
                
                
            </div>
        </div>
        
        <div class="content">
            <h2 id="交换机日常维护检测命令"><a href="#交换机日常维护检测命令" class="headerlink" title="交换机日常维护检测命令"></a>交换机日常维护检测命令</h2><h2 id="风扇"><a href="#风扇" class="headerlink" title="风扇"></a>风扇</h2><p>查看风扇状态</p>
<pre><code class="bash">system-view 
display fan</code></pre>
<p>损坏状态:</p>
<pre><code class="text">[ONI-KC-I06-A02]display fan
 Slot 1
      FAN    1
      State    : Fault</code></pre>
<p>正常运行状态</p>
<pre><code class="text">[ONI-KC-I05-A01]display fan
 Slot 1
      FAN    1
      State    : Normal</code></pre>
<h2 id="arp表项"><a href="#arp表项" class="headerlink" title="arp表项"></a>arp表项</h2><p>查看arp表项</p>
<pre><code class="bash">system-view
display arp</code></pre>
<p>结果:</p>
<pre><code class="text">  Type: S-Static   D-Dynamic   O-Openflow   R-Rule   M-Multiport  I-Invalid
IP address      MAC address    VID        Interface/Link ID        Aging Type 
10.0.0.62       0080-91b5-ae52 1000       GE1/0/48                 402   D    
10.0.0.130      84d9-317f-57c4 1000       GE1/0/48                 1197  D    
10.0.0.133      70f9-6d0d-e1c3 1000       GE1/0/48                 1078  D    
10.0.0.134      70f9-6d0d-e1c0 1000       GE1/0/48                 611   D    
10.0.0.135      5cdd-707a-2215 1000       GE1/0/48                 1078  D    
10.0.0.136      5cdd-707a-2212 1000       GE1/0/48                 609   D    
10.0.0.137      487a-da9c-21aa 1000       GE1/0/48                 559   D    
10.0.0.138      487a-da9c-20d2 1000       GE1/0/48                 213   D    
10.0.0.150      70f9-6ddc-7719 1000       GE1/0/48                 612   D    
10.0.0.161      5cdd-7008-82d8 1000       GE1/0/48                 864   D    
10.0.0.162      3ce5-a6af-fb39 1000       GE1/0/48                 612   D    
10.0.0.163      70f9-6d4a-d07d 1000       GE1/0/48                 610   D    
10.0.0.164      5cdd-7095-0c41 1000       GE1/0/48                 609   D    
10.0.0.165      7425-8ad9-0d84 1000       GE1/0/48                 611   D    
10.0.0.166      7425-8ad9-0924 1000       GE1/0/48                 611   D    
10.0.0.167      70f9-6d4a-c4ed 1000       GE1/0/48                 610   D    
10.0.0.168      5cdd-70a5-bc53 1000       GE1/0/48                 612   D    
10.0.0.169      50da-00f2-0c06 1000       GE1/0/48                 610   D    
10.0.0.170      845b-125c-381b 1000       GE1/0/48                 1185  D    
10.0.0.171      586a-b106-39f4 1000       GE1/0/48                 1071  D    
10.0.0.173      586a-b106-6994 1000       GE1/0/48                 1071  D</code></pre>
<p>其中包括IP地址 mac地址等</p>
<h2 id="接口信息"><a href="#接口信息" class="headerlink" title="接口信息"></a>接口信息</h2><pre><code class="bash">system-view 
display interface brief </code></pre>
<h2 id="环路检测显示和维护"><a href="#环路检测显示和维护" class="headerlink" title="环路检测显示和维护"></a>环路检测显示和维护</h2><pre><code class="bash">system-view
display loopback-detection</code></pre>
<h2 id="时间显示"><a href="#时间显示" class="headerlink" title="时间显示"></a>时间显示</h2><pre><code class="bash">display clock</code></pre>
<p><strong>修改时间</strong><br>1.获取NTP,由网络时钟服务器获取时间<br>clock protocol ntp mdc [mdc-ip]<br>2.不设置时钟服务器<br>clock protoco none</p>
<pre><code class="bash">&lt;H3C&gt;clock protocol none　　　　　　　　　　　　　　#关闭protocol ,缺省情况下，默认开启，由缺省MDC获取系统时间

&lt;H3C&gt;clock datetime hh:mm:ss year/month/day　　　　 #设置时间

[H3C]clock timezone beijing add 8　　　　　　　　　　#设置时区 北京 在UTC偏移8小时

[H3C]quit</code></pre>
<h2 id="显示Switch-A上全局和所有接口的LLDP状态信息。"><a href="#显示Switch-A上全局和所有接口的LLDP状态信息。" class="headerlink" title="显示Switch A上全局和所有接口的LLDP状态信息。"></a>显示Switch A上全局和所有接口的LLDP状态信息。</h2><pre><code class="bash">[SwitchA] display lldp status</code></pre>
<p>结果:</p>
<pre><code class="bash">LLDP status information of port 1 [Ten-GigabitEthernet1/0/1]:
LLDP agent nearest-bridge:
Port status of LLDP            : Enable
Admin status                   : RX_Only
Trap flag                      : No
MED trap flag                  : No
Polling interval               : 0s
Number of LLDP neighbors       : 1
Number of MED neighbors        : 1
Number of CDP neighbors        : 0
Number of sent optional TLV    : 21
Number of received unknown TLV : 0</code></pre>
<h2 id="FIB表的信息-ip转发信息表"><a href="#FIB表的信息-ip转发信息表" class="headerlink" title="FIB表的信息(ip转发信息表)"></a>FIB表的信息(ip转发信息表)</h2><pre><code class="bash">[hzj_test]display fib </code></pre>
<p>结果：</p>
<pre><code class="bash">[hzj_test]display  fib 

Destination count: 17 FIB entry count: 17

Flag:
  U:Useable   G:Gateway   H:Host   B:Blackhole   D:Dynamic   S:Static
  R:Relay     F:FRR 

Destination/Mask   Nexthop         Flag     OutInterface/Token       Label
0.0.0.0/32         127.0.0.1       UH       InLoop0                  Null       
10.0.0.0/20        10.0.5.124      U        Vlan1000                 Null       
10.0.0.0/32        10.0.5.124      UBH      Vlan1000                 Null       
10.0.1.19/32       10.0.1.19       UH       Vlan1000                 Null       
10.0.1.54/32       10.0.1.54       UH       Vlan1000                 Null       
10.0.1.70/32       10.0.1.70       UH       Vlan1000                 Null       
10.0.1.71/32       10.0.1.71       UH       Vlan1000                 Null       
10.0.2.56/32       10.0.2.56       UH       Vlan1000                 Null       
10.0.5.124/32      127.0.0.1       UH       InLoop0                  Null       
10.0.15.255/32     10.0.5.124      UBH      Vlan1000                 Null       
127.0.0.0/8        127.0.0.1       U        InLoop0                  Null       
127.0.0.0/32       127.0.0.1       UH       InLoop0                  Null       
127.0.0.1/32       127.0.0.1       UH       InLoop0                  Null       
127.255.255.255/32 127.0.0.1       UH       InLoop0                  Null       
224.0.0.0/4        0.0.0.0         UB       NULL0                    Null       
224.0.0.0/24       0.0.0.0         UB       NULL0                    Null       
255.255.255.255/32 127.0.0.1       UH       InLoop0                  Null    </code></pre>
<p>FIB表中包含了下列关键项：</p>
<ul>
<li>Destination：目的地址。用来标识IP报文的目的地址或目的网络。</li>
<li>Mask：网络掩码。与目的地址一起来标识目的主机或交换机所在的网段的地址。将目的地址和网络掩码“逻辑与”后可得到目的主机或交换机所在网段的地址。例如：目的地址为192.168.1.40、掩码为255.255.255.0的主机或交换机所在网段的地址为192.168.1.0。掩码由若干个连续“1”构成，既可以用点分十进制法表示，也可以用掩码中连续“1”的个数来表示。</li>
<li>NextHop：转发的下一跳地址。</li>
<li>Flag：路由的标志。</li>
<li>OutInterface：转发接口。指明IP报文将从哪个接口转发。</li>
<li>Token：LSP（Label Switched Path，标签交换路径）索引号。</li>
<li>Label：内层标签值</li>
</ul>
<h2 id="风扇-1"><a href="#风扇-1" class="headerlink" title="风扇"></a>风扇</h2><p>查看风扇状态</p>
<pre><code class="bash">system-view 
display fan</code></pre>
<p>损坏状态:</p>
<pre><code class="text">[ONI-KC-I06-A02]display fan
 Slot 1
      FAN    1
      State    : Fault</code></pre>
<p>正常运行状态</p>
<pre><code class="text">[ONI-KC-I05-A01]display fan
 Slot 1
      FAN    1
      State    : Normal</code></pre>
<h2 id="arp表项-1"><a href="#arp表项-1" class="headerlink" title="arp表项"></a>arp表项</h2><p>查看arp表项</p>
<pre><code class="bash">system-view
display arp</code></pre>
<p>结果:</p>
<pre><code class="text">  Type: S-Static   D-Dynamic   O-Openflow   R-Rule   M-Multiport  I-Invalid
IP address      MAC address    VID        Interface/Link ID        Aging Type 
10.0.0.62       0080-91b5-ae52 1000       GE1/0/48                 402   D    
10.0.0.130      84d9-317f-57c4 1000       GE1/0/48                 1197  D    
10.0.0.133      70f9-6d0d-e1c3 1000       GE1/0/48                 1078  D    
10.0.0.134      70f9-6d0d-e1c0 1000       GE1/0/48                 611   D    
10.0.0.135      5cdd-707a-2215 1000       GE1/0/48                 1078  D    
10.0.0.136      5cdd-707a-2212 1000       GE1/0/48                 609   D    
10.0.0.137      487a-da9c-21aa 1000       GE1/0/48                 559   D    
10.0.0.138      487a-da9c-20d2 1000       GE1/0/48                 213   D    
10.0.0.150      70f9-6ddc-7719 1000       GE1/0/48                 612   D    
10.0.0.161      5cdd-7008-82d8 1000       GE1/0/48                 864   D    
10.0.0.162      3ce5-a6af-fb39 1000       GE1/0/48                 612   D    
10.0.0.163      70f9-6d4a-d07d 1000       GE1/0/48                 610   D    
10.0.0.164      5cdd-7095-0c41 1000       GE1/0/48                 609   D    
10.0.0.165      7425-8ad9-0d84 1000       GE1/0/48                 611   D    
10.0.0.166      7425-8ad9-0924 1000       GE1/0/48                 611   D    
10.0.0.167      70f9-6d4a-c4ed 1000       GE1/0/48                 610   D    
10.0.0.168      5cdd-70a5-bc53 1000       GE1/0/48                 612   D    
10.0.0.169      50da-00f2-0c06 1000       GE1/0/48                 610   D    
10.0.0.170      845b-125c-381b 1000       GE1/0/48                 1185  D    
10.0.0.171      586a-b106-39f4 1000       GE1/0/48                 1071  D    
10.0.0.173      586a-b106-6994 1000       GE1/0/48                 1071  D</code></pre>
<p>其中包括IP地址 mac地址等</p>
<h2 id="接口信息-1"><a href="#接口信息-1" class="headerlink" title="接口信息"></a>接口信息</h2><pre><code class="bash">system-view 
display interface brief </code></pre>
<h2 id="环路检测显示和维护-1"><a href="#环路检测显示和维护-1" class="headerlink" title="环路检测显示和维护"></a>环路检测显示和维护</h2><pre><code class="bash">system-view
display loopback-detection</code></pre>
<h2 id="确认arp表数量"><a href="#确认arp表数量" class="headerlink" title="确认arp表数量"></a>确认arp表数量</h2><pre><code class="bash">display arp all </code></pre>
<p>cnblogs.com/dpwindy/p/9104330.html</p>

        </div>
        
        
        
        
    </div>
</div>









    <div class="card">
    
    <div class="card-content article ">
        <h1 class="title is-size-3 is-size-4-mobile has-text-weight-normal">
            
                <a class="has-link-black-ter" href="/2020/01/03/blog_back_new/%E7%BD%91%E7%BB%9C/%E4%BA%A4%E6%8D%A2%E6%9C%BA%E5%85%89%E6%A8%A1%E5%9D%97%E6%A3%80%E6%B5%8B/"><i class="fas fa-angle-double-right"></i>交换机光模块维护检测</a>
            
        </h1>
        
        <div class="level article-meta is-size-7 is-uppercase is-mobile is-overflow-x-auto">
            <div class="level-left">
                <time class="level-item has-text-grey" datetime="2020-01-03T02:41:44.000Z"><i class="far fa-calendar-alt">&nbsp;</i>2020-01-03</time>
                
                <time class="level-item has-text-grey is-hidden-mobile" datetime="2020-01-04T00:30:09.732Z"><i class="far fa-calendar-check">&nbsp;</i>2020-01-04</time>
                
                
                <div class="level-item">
                <i class="far fa-folder-open has-text-grey"></i>&nbsp;
                <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a>&nbsp;/&nbsp;<a class="has-link-grey -link" href="/categories/blog-back-new/%E7%BD%91%E7%BB%9C/">网络</a>
                </div>
                
                
                <span class="level-item has-text-grey">
                    <i class="far fa-clock"></i>&nbsp;
                    
                    
                    2 minutes read (About 373 words)
                </span>
                
                
            </div>
        </div>
        
        <div class="content">
            <h2 id="H3c光模块相关命令和检测方式"><a href="#H3c光模块相关命令和检测方式" class="headerlink" title="H3c光模块相关命令和检测方式"></a>H3c光模块相关命令和检测方式</h2><p>几个光模块检测命令</p>
<pre><code class="bash"># 显示光模块的部分电子标签信息
display transceiver manuinfo interface GigabitEthernet 1/0/50
&lt;FRR_TEST_6800-54QF&gt;display transceiver interface Ten-GigabitEthernet 1/0/47
Ten-GigabitEthernet1/0/47 transceiver information:
  Transceiver Type              : 10G_BASE_SR_SFP        # 设备型号
  Connector Type                : No Separable Connector # 连接
  Wavelength(nm)                : 850      # 显示发送激光中心波长
  Transfer Distance(m)          : 5(No Separable Connector) # 传输距离
  Digital Diagnostic Monitoring : YES # 是否支持数字诊断功能
  Vendor Name                   : Gigalight # 定制厂商名称 即 H3c
  Vendor Part Number            : GSS-MDO100-005C # 对外型号

# 显示可插拔模块的主要特征参数
display transceiver interface GigabitEthernet 1/0/50 
# 显示光模块数字诊断参数的当前测量值
display transceiver Diagnostic interface GigabitEthernet 1/0/50
# 信息可见一下，其中 
# channel 表示四个发光口的数据
# module 表示模块状态
# alarm 表示基本校验信息</code></pre>
<ul>
<li>RX power表示收光信息</li>
<li>Tx power表示发光信息</li>
<li>Basic 偏置电流</li>
<li>Voltage 电压</li>
<li>temp 温度</li>
<li>Alarm thresholds 表示报警阀值</li>
</ul>
<h2 id="交换机光模块维护检测"><a href="#交换机光模块维护检测" class="headerlink" title="交换机光模块维护检测"></a>交换机光模块维护检测</h2><p><font color='blue'>已知 49口40G模块疑似坏掉，检测规则</font></p>
<p>40 —–  50 口互相连接<br><img src="http://img.noback.top/2020-01-03-10-30-39.png" alt="2020-01-03-10-30-39"><br>无收光时 40G模块  50口<br><img src="http://img.noback.top/2020-01-03-10-31-37.png" alt="2020-01-03-10-31-37"><br>有收光时，40G模块  50口</p>
<p><img src="http://img.noback.top/2020-01-03-10-32-50.png" alt="2020-01-03-10-32-50"><br>无收光时， 40G模块  49口<br><img src="http://img.noback.top/2020-01-03-10-33-26.png" alt="2020-01-03-10-33-26"><br>有收光时， 40G模块  49口</p>
<p><font color='blue'>以上会发现40口模块虽然收发光正常，但是在50口收光处只收到了2束光，说明在40G处发光有问题</font></p>
<p>坏模块SN号<br><img src="http://img.noback.top/2020-01-03-10-48-35.png" alt="2020-01-03-10-48-35"></p>

        </div>
        
        
        
        
    </div>
</div>









    <div class="card">
    
    <div class="card-content article ">
        <h1 class="title is-size-3 is-size-4-mobile has-text-weight-normal">
            
                <a class="has-link-black-ter" href="/2020/01/02/blog_back_new/Python/python-re%E6%A8%A1%E5%9D%97/"><i class="fas fa-angle-double-right"></i>Python-re模块</a>
            
        </h1>
        
        <div class="level article-meta is-size-7 is-uppercase is-mobile is-overflow-x-auto">
            <div class="level-left">
                <time class="level-item has-text-grey" datetime="2020-01-02T05:56:28.000Z"><i class="far fa-calendar-alt">&nbsp;</i>2020-01-02</time>
                
                <time class="level-item has-text-grey is-hidden-mobile" datetime="2020-01-03T06:26:25.505Z"><i class="far fa-calendar-check">&nbsp;</i>2020-01-03</time>
                
                
                <div class="level-item">
                <i class="far fa-folder-open has-text-grey"></i>&nbsp;
                <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a>&nbsp;/&nbsp;<a class="has-link-grey -link" href="/categories/blog-back-new/Python/">Python</a>
                </div>
                
                
                <span class="level-item has-text-grey">
                    <i class="far fa-clock"></i>&nbsp;
                    
                    
                    4 minutes read (About 578 words)
                </span>
                
                
            </div>
        </div>
        
        <div class="content">
            <h2 id="Python-正则表达式-re模块"><a href="#Python-正则表达式-re模块" class="headerlink" title="Python 正则表达式 re模块"></a>Python 正则表达式 re模块</h2><p>正则表达式在很多文本匹配中都要用到，在python中我们用到re模块，由于经常会忘记，记录一下已做备用<br>3.8版本官网地址<a href="https://docs.python.org/zh-cn/3/library/re.html#" target="_blank" rel="noopener">https://docs.python.org/zh-cn/3/library/re.html#</a></p>
<h2 id="使用正则表达式"><a href="#使用正则表达式" class="headerlink" title="使用正则表达式"></a>使用正则表达式</h2><p>匹配流程:<br>编写表达式引擎，编译成对象，获取匹配文本，得出匹配结果</p>
<h3 id="元字符"><a href="#元字符" class="headerlink" title="元字符"></a>元字符</h3><p>1) “.” 可以只带所有字符，除了换行符\n,一个点对应一个字符<br>2) “^” 从整个字符串开头的地方匹配<br>3) “$” 从整个字符出啊弄的结尾开始匹配<br>4）”*” 重复匹配0到无穷次<br>5) “+” 重复匹配1到无穷次<br>6）”?”  匹配一次或0次 [0,1]<br>7) “x{nums}” 匹配x nums次<br>8) “[]” 字符集，”[-]” 字符集+字符区间 匹配区间内任意字符<br>9) “&quot; </p>
<pre><code class="bash">\d # 表示 匹配任何十进制数 相当于[0-9]
\D # 表示 匹配非数字字符，相当于[^0-9]
\s # 表示 匹配任何空白字符 相当于[\t\n\r\f\v]
\S # 表示 匹配任何非空白字符 相当于[^\t\n\r\f\v]
\w # 表示 匹配任何字母数字字符  相当于[a-zA-Z0-9]
\W # 表示 匹配任何非字母数字字符，相当于 [^a-zA-Z0-9]
\b # 表示 匹配一个单词边界，</code></pre>
<p>10) () 将括号中的内容 当作整体来对待<br>11) | 表示或</p>
<h3 id="方法"><a href="#方法" class="headerlink" title="方法"></a>方法</h3><ul>
<li>findall() 全部找到，返回一个列表</li>
<li>search() 匹配处第一个满足条件的结果，返回的是一个对象，可以通过调用group方法</li>
<li>match() 返回匹配到的第一个对象，只在字符串开始匹配<pre><code class="bash">#注意：
# match()  只检测RE是不是在string的开始位置匹配， 
# search() 会扫描整个string查找匹配；
# 也就是说match() 只有在0位置匹配成功的话才有返回，如果不是开始位置匹配成功的话，match()就返回none</code></pre>
</li>
<li>split() 分隔符 返回列表<pre><code class="python">result = re.split(&quot;j&quot;,&quot;xsxsdsjdlsajdlj j j j j&quot;) 
result = re.split(&quot;[j,k]&quot;,&quot;ddsdjsjk xkskd;l lk;ld;s&quot;)
# 数组分隔会先更根据j分隔 再根据k分隔</code></pre>
</li>
<li>sub() 替换 类似于字符串的replace方法<pre><code class="bash">ret = re.sub(&quot;a..x&quot;,&#39;hzj&#39;,&#39;hello,alex&#39;)
print(ret) # ==&gt; hello,hzj </code></pre>
</li>
</ul>
<h2 id="扩展"><a href="#扩展" class="headerlink" title="扩展"></a>扩展</h2><p><a href="https://docs.python.org/zh-cn/3/library/re.html#" target="_blank" rel="noopener">https://docs.python.org/zh-cn/3/library/re.html#</a></p>

        </div>
        
        
        
        
    </div>
</div>









    <div class="card">
    
    <div class="card-content article ">
        <h1 class="title is-size-3 is-size-4-mobile has-text-weight-normal">
            
                <a class="has-link-black-ter" href="/2019/12/29/blog_back_new/ansible/ansible%E5%9F%BA%E7%A1%80/"><i class="fas fa-angle-double-right"></i>ansible基础</a>
            
        </h1>
        
        <div class="level article-meta is-size-7 is-uppercase is-mobile is-overflow-x-auto">
            <div class="level-left">
                <time class="level-item has-text-grey" datetime="2019-12-29T12:54:37.000Z"><i class="far fa-calendar-alt">&nbsp;</i>2019-12-29</time>
                
                <time class="level-item has-text-grey is-hidden-mobile" datetime="2019-12-29T12:59:13.819Z"><i class="far fa-calendar-check">&nbsp;</i>2019-12-29</time>
                
                
                <div class="level-item">
                <i class="far fa-folder-open has-text-grey"></i>&nbsp;
                <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a>&nbsp;/&nbsp;<a class="has-link-grey -link" href="/categories/blog-back-new/ansible/">ansible</a>
                </div>
                
                
                <span class="level-item has-text-grey">
                    <i class="far fa-clock"></i>&nbsp;
                    
                    
                    22 minutes read (About 3288 words)
                </span>
                
                
            </div>
        </div>
        
        <div class="content">
            <h2 id="主机清单-inventory"><a href="#主机清单-inventory" class="headerlink" title="主机清单 inventory"></a>主机清单 inventory</h2><p>ansible中添加主机清单的几种形式</p>
<ol>
<li><p>直接在命令行中指定ip,-k登陆时指定密码</p>
<pre><code class="bash">ansible 192.168.20.1 -m ping -k
ansible 192.168.20.1,192.168.20.2 -m ping -k</code></pre>
</li>
<li><p>在配置文件中指定  默认文件夹/etc/ansible/hosts</p>
</li>
</ol>
<pre><code class="bash">[name1]
192.168.20.1
[name2]
192.168.20.2
ansible name1 -m ping -k # 指定分组
ansible all -m ping -k # 指定所有</code></pre>
<p><img src="http://img.noback.top/blog/img/20190902/ansible2.png" alt=""><br>由于ansible是通过ssh访问被执行端主机的，因此没有ssh的权限是无法完成任务的，即使这里的命令是ping，但依旧要走ssh的流程<br>这里的ping并不是linux下的ping ,而是ansible工具下面的ping模块</p>
<ol start="3">
<li><p>不使用默认文件下，自定义文件夹</p>
<pre><code class="bash">echo &quot;192.168.20.1&quot;  &gt;&gt; xx
ansible -i xx all -m ping -k</code></pre>
</li>
<li><p>在配置组里面中直接确认登陆用户</p>
<pre><code class="bash">echo &quot;192.168.20.1 ansible_ssh_user=root ansible_ssh_pass=upyun123&quot;
ansible -i xx all -m ping </code></pre>
</li>
</ol>
<hr>
<h2 id="配置文件"><a href="#配置文件" class="headerlink" title="配置文件"></a>配置文件</h2><ol>
<li>local_tmp是本地的执行指令</li>
<li>remote_tmp是远程的执行指令<br>当用户使用ansible控制被控端执行指令的时候，他会先将内容放在local_tmp文件中，然后上传到被控端并生成remote_tmp上执行。执行完成之后会删除这两个tmp文件</li>
<li>library = /usr/share/my_modules/ 库存放地址</li>
<li>forks = 5 默认并发数</li>
<li>sudo_user = root 默认sudo 用户</li>
<li>ask_sudo_pass = True  每次执行ansible是否询问ssh密码</li>
<li>ask_pass = True</li>
<li>remote_port = 22</li>
<li>host_key_checking = False 检查对应服务器的host_key —–&gt;建议取消注释</li>
<li>log_path=/var/log/ansible.log 日志文件 </li>
</ol>
<h2 id="命令"><a href="#命令" class="headerlink" title="命令"></a>命令</h2><h4 id="ansible-doc-说明文档"><a href="#ansible-doc-说明文档" class="headerlink" title="ansible-doc 说明文档"></a>ansible-doc 说明文档</h4><p>ansible-doc [options] [module..]<br>-a 显示所有模块的文档 参数尽量放在单引号里面<br>-l –list 列出可用模块<br>-s –snippet xxx 显示xxx模块的playbook片段</p>
<p>role扩展模块<br>ansible-galaxy专门有一个网站提供不同用户上传的”角色”<br>地址:<a href="https://galaxy.ansible.com/" target="_blank" rel="noopener">https://galaxy.ansible.com/</a></p>
<pre><code class="bash"># 列出所有已安装的galaxy
ansible-galaxy list
# 安装galaxy
ansible-galaxy install xxx
# 删除galaxy
ansible-galaxy remove xxx</code></pre>
<p>role默认安装路径为/etc/ansible/roles/下</p>
<h4 id="ansible"><a href="#ansible" class="headerlink" title="ansible"></a>ansible</h4><p>列出指定组别的host列表<br>ansible appsevr –list-hosts<br>列出所有列表的host<br>ansible all –list-hosts<br>ansible all –list<br>支持通配符匹配host<br>ansible *serv –list<br>多IP批量执行<br>ansible 192.168.0.1,192.168.0.2 -m ping<br>多组别批量执行(逻辑或关系,合并，A和B所有)<br>ansible websevr:appsevr -m ping<br>(逻辑与关系,区分,在A中,也在B中)<br>ansible “websevr:&amp;appsevr” -m ping<br>(逻辑非,在A中不在B中,此处必须要用单引号)<br>ansible ‘websevr:!appsevr’ -m ping </p>
<p>ansible <host-pattern> [-m module_name] [-a args]<br>–version 显示版本<br>-m module 指定模板,默认为command<br>-v 详细过程 -vv -vvv更详细<br>–list –list-hosts 显示主机列表，<br>-k –ask-pass 提示输入ssh连接密码，默认为key验证<br>-K –ask-become-pass 提示输入sudo时的口令<br>-C –check 检查，并不执行<br>-T –timeout=TIMEOUT 执行命令的超时时间,默认为10s<br>-u –user=REMOTE_USER 执行远程执行的用户<br>-b –become 代替旧版的sudo切换 (默认为ansible.cfg里面设置的用户,一般为root)<br>-a 指定参数</p>
<h4 id="ansible-m命令模块"><a href="#ansible-m命令模块" class="headerlink" title="ansible -m命令模块"></a>ansible -m命令模块</h4><h5 id="command"><a href="#command" class="headerlink" title="command"></a>command</h5><p>在command中,我们可以创建文件，但是对于文件的操作,有一个专门的file模块</p>
<pre><code class="bash"># 创建一个文件
ansible -m command -a &#39;mkdir \data&#39;
# 查看文件是否创建成功
ansible -m command -a &#39;ls -al \data&#39;
# 查看command帮助
ansible-doc command</code></pre>
<h5 id="shell"><a href="#shell" class="headerlink" title="shell"></a>shell</h5><p>如果-a 后带的参数中出现 $ &lt; &gt; | ;  &amp; 等字符，command是不支持的，需要用到shell 模块</p>
<pre><code class="bash"># 输出主机名字
ansible 192.168.1.3 -m shell -a &#39;echo $HOSTNAME&#39;  </code></pre>
<h2 id="ansible命令执行流程"><a href="#ansible命令执行流程" class="headerlink" title="ansible命令执行流程"></a>ansible命令执行流程</h2><p>1.加载自己的配置文件 默认为/etc/ansible/ansible.cfg<br>2.加载自己对应的模块文件,如command<br>3.通过ansible将模块或命令生成对应的临时py文件,并将文件传输至远程服务器的对应执行用户$HOME/.ansible/tmp/ansible-tmp-数字/xxx.py文件<br>4.增加文件的执行权限<br>5.执行并返回结果<br>6.删除临时py文件,sleep 0退出<br>执行状态:<br>绿色 执行成功并且不需要做改变的操作<br>黄色 执行成功但是对目标主机做了修改<br>红色 执行失败<br>(颜色内容在/etc/ansible.cfg里面修改)</p>
<p><strong>生成ssh</strong><br>ssh-keygen<br><strong>复制ssh密钥到其他主机</strong><br>ssh-copy-id 主机ip</p>
<hr>
<h2 id="模块"><a href="#模块" class="headerlink" title="模块"></a>模块</h2><p>由于Ansible的模块过多，将近有1378个模块数量,但是每个模块的介绍以及使用方法都存放在/usr/bin/ansible-doc当中</p>
<pre><code class="bash"># 查看当前ansible模块数量
ansible-doc -l | wc -l
# ansible-doc的使用方法
ansible-doc [options] [module..]
-a 显示所有模块的文档 参数尽量放在单引号里面
-l --list 列出可用模块
-s --snippet xxx 显示xxx模块的playbook片段
# 使用-m指定模块，默认为command
ansible -m command</code></pre>
<h3 id="command-1"><a href="#command-1" class="headerlink" title="command"></a>command</h3><p>在command中,我们可以创建文件，但是对于文件的操作,有一个专门的file模块</p>
<pre><code class="bash"># 创建一个文件
ansible -m command -a &#39;mkdir \data&#39;
# 查看文件是否创建成功
ansible -m command -a &#39;ls -al \data&#39;
# 查看command帮助
ansible-doc command</code></pre>
<h3 id="shell-1"><a href="#shell-1" class="headerlink" title="shell"></a>shell</h3><p>如果-a 后带的参数中出现 $ &lt; &gt; | ;  &amp; 等字符，command是不支持的，需要用到shell 模块</p>
<pre><code class="bash"># 输出主机名字
ansible 192.168.1.3 -m shell -a &#39;echo $HOSTNAME&#39;  </code></pre>
<h3 id="script"><a href="#script" class="headerlink" title="script"></a>script</h3><p>既然ansible可以对多台主机进行批量的操作，那往往我们会遇到一个场景，即需要我们在多台主机上执行一个脚本，这个场景下我们有两个方法:<br>1.将脚本文件复制到多台主机上后,调用ansible使用<br>2.使用script模块，仅在控制端存在脚本文件即可</p>
<pre><code class="bash"># 方法一,先将文件发到对应控制端主机
ansible 192.168.1.3 -m command -a &#39;/root/ansible_test.sh&#39;
# 方法二
root@DESKTOP-GT1K5L0:~# ansible 192.168.1.3 -m script -a &#39;/root/ansible_test.sh&#39;
192.168.1.3 | SUCCESS =&gt; {
    &quot;changed&quot;: true,
    &quot;rc&quot;: 0,
    &quot;stderr&quot;: &quot;Shared connection to 192.168.1.3 closed&quot;,
    &quot;stdout&quot;: &quot;to do it,ansible&quot;,
    &quot;stdout_lines&quot;: [
        &quot;to do it,ansible&quot;
    ]
} </code></pre>
<h3 id="Copy"><a href="#Copy" class="headerlink" title="Copy"></a>Copy</h3><p>在上面我们提到了从控制端传输文件到被控端,既然是批量的操作,那么在ansible中同样存在一个copy的模块,可以用来传输文件<br>场景: 关闭多台主机的selinux<br>流程: 复制控制端selinux的配置文件，修改后发送到被控制端</p>
<p>注意:这里的ho表示的是一个主机群 在/etc/ansible/hosts中已经添加了</p>
<pre><code class="bash"># 查看控制端selinux状态
getenforce

# 查看被控端selinux状态
[root@localhost ~]# ansible ho -m command -a &#39;getenforce&#39;
192.168.1.6 | SUCCESS | rc=0 &gt;&gt;
Enforcing
192.168.1.7 | SUCCESS | rc=0 &gt;&gt;
Enforcing
192.168.1.5 | SUCCESS | rc=0 &gt;&gt;
Enforcing
192.168.1.4 | SUCCESS | rc=0 &gt;&gt;
Enforcing

# 复制selinux配置文件，并修改配置
cp /etc/selinux/config  .
SELINUX=disabled

# 复制配置文件到被控端指定路径,并做好备份
ansible ho -m copy -a&#39;src=/root/hzj/config dest=/etc/selinux/config backup=yes&#39;

# 查看被控端是否生成备份文件
ansible ho -m command -a &#39;ls /etc/selinux/&#39;

# 重启
ansible ho -m command -a &#39;reboot&#39;
# 查看被控端selinux是否修改完成
ansible ho -m command -a &#39;getenforce&#39;
[root@localhost hzj]# ansible ho -m command -a &#39;getenforce&#39;
192.168.1.7 | SUCCESS | rc=0 &gt;&gt;
Disabled
192.168.1.4 | SUCCESS | rc=0 &gt;&gt;
Disabled
192.168.1.5 | SUCCESS | rc=0 &gt;&gt;
Disabled
192.168.1.6 | SUCCESS | rc=0 &gt;&gt;
Disabled</code></pre>
<h3 id="fetch"><a href="#fetch" class="headerlink" title="fetch"></a>fetch</h3><p>ansible支持从被控端抓取文件到控制端,抓取后的格式为\example.com\dest<br>src表示抓取路径<br>dest表示存放路径</p>
<pre><code class="bash"># 复制所有主机的日志到控制端
ansible ho -m fetch -a &#39;src=/var/log/messages dest=/root/data&#39;</code></pre>
<p>但是fetch仅支持单个文件的抓取，当我们想要抓取多个日志文件时，可以先进行打包</p>
<h3 id="file"><a href="#file" class="headerlink" title="file"></a>file</h3><p>设置文件的属性</p>
<pre><code class="bash"># 创建文件
ansible ho -m file -a &#39;name=/data/f3 state=touch&#39;
# 删除文件
ansible ho -m file -a &#39;name=/data/f3 state=absent&#39;
# 创建文件夹
ansible ho -m file -a &#39;name=/data/f3 state=directory&#39;
# 删除文件夹
ansible ho -m file -a &#39;name=/data/f3 state=absent&#39;
# 创建软连接
ansible ho -m file -a &#39;src=/root/test name=/data/fq state=link&#39;

# 但是需要注意的是如果你创建了文件f3 当你创建文件夹f3的时候会出现错误</code></pre>
<h3 id="hostname"><a href="#hostname" class="headerlink" title="hostname"></a>hostname</h3><p>修改主机名</p>
<pre><code class="bash">ansible ho -m hostname -a &#39;name=node&#39;
# 重启后生效</code></pre>
<h3 id="cron"><a href="#cron" class="headerlink" title="cron"></a>cron</h3><pre><code class="bash"># 给每台主机添加任务,name为注释
ansible ho -m cron -a &#39;minute=* weekday=1,3,5,7 job=&quot;usr/bin/wall message&quot;  name=test&#39;
# 取消任务
ansible ho -m cron -a &#39;disabled=true job=&quot;usr/bin/wall message&quot; name=test&#39;
# 重新启用
ansible ho -m cron -a &#39;disabled=no job=&quot;usr/bin/wall message&quot; name=test&#39;
# 删除某条任务
ansible ho -m corn -a &#39;jon=&quot;usr/bin/wall message&quot; state=absent&#39;</code></pre>
<h3 id="yum"><a href="#yum" class="headerlink" title="yum"></a>yum</h3><pre><code class="bash"># name指定包  state指定状态
ansible ho -m yum -a &#39;name=httpd state=latest&#39; 安装
ansible ho -m yum -a &#39;name=httpd state=absent&#39; 删除</code></pre>
<h3 id="Service"><a href="#Service" class="headerlink" title="Service"></a>Service</h3><pre><code class="bash"># 关闭服务  name指定服务名称  state指定状态
ansible ho -m service -a &#39;name=httpd state=stopped&#39;
ansible ho -m service -a &#39;name=httpd state=started&#39;
ansible ho -m service -a&#39;name=httpd state=reloaded&#39;
ansible ho -m service -a&#39;name=httpd state=restarted&#39;</code></pre>
<h3 id="User"><a href="#User" class="headerlink" title="User"></a>User</h3><pre><code class="bash">ansible ho -m user -a &#39;name=user comment=&quot;test user&quot; uid=2048 home=/app/user group=root&#39;
ansible ho -m user -a &#39;name=sysuser system=yes home=/app/syseser1&#39;
ansible ho -m user -a &#39;name=user state=absent remove=yes&#39; 删除用户以及家目录等数据</code></pre>
<h2 id="playbook的编写"><a href="#playbook的编写" class="headerlink" title="playbook的编写"></a>playbook的编写</h2><p>随着工作的增加,单条ansible命令(adhoc)已经不能满足我们的需求.于是我们可以把多条ansible命令写入playbook中,让系统根据playbook中的顺序依次执行ansible。我们把它叫做剧本</p>
<h3 id="Playbook的编写方式"><a href="#Playbook的编写方式" class="headerlink" title="Playbook的编写方式"></a>Playbook的编写方式</h3><p>Playbook的编写格式采用的是yaml语言<br>url: <a href="http://www.ruanyifeng.com/blog/2016/07/yaml.html" target="_blank" rel="noopener">http://www.ruanyifeng.com/blog/2016/07/yaml.html</a><br>url2: <a href="https://www.jianshu.com/p/97222440cd08" target="_blank" rel="noopener">https://www.jianshu.com/p/97222440cd08</a><br>urs3: <a href="https://yaml.org/" target="_blank" rel="noopener">https://yaml.org/</a>  多种语言实现yaml</p>
<p>简单的介绍一下yaml语言的使用</p>
<pre><code class="text">1. 在单一档案中,可以用连续的连字符(---)区分多个档案。另外，还有选择性的连续三个点号(...)用来表示档案结尾
2. 次行开始正常写Playbook的内容，一般建议写明该playbook的功能
3. 使用#号注释代码
4. 缩进统一用tab
5. 一个完整的代码块功能最少的元素需要包括name:task
6. 一个name只能包括一个task
7. yaml文件扩展名通常为yml或者yaml
</code></pre>
<p>playbook例子</p>
<pre><code class="bash">---
- hosts: webservers
  vars:
    http_port: 80
    max_clients: 200
  remote_user: root
  tasks:
  - name: ensure apache is at the latest version
    yum: pkg=httpd state=latest
  - name: write the apache config file
    template: src=/srv/httpd.j2 dest=/etc/httpd.conf
    notify:
    - restart apache
  - name: ensure apache is running
    service: name=httpd state=started
  handlers:
    - name: restart apache
      service: name=httpd state=restarted</code></pre>
<p><strong>playbook核心元素</strong></p>
<ul>
<li>Hosts 执行的远程主机列表</li>
<li>Tasks 任务集</li>
<li>Varniables 内置变量或自定义变量在playbook中调用</li>
<li>Templates 模板,可替换模板文件中的变量并实现一些简单逻辑的文件</li>
<li>Handlers 和 notity 结合使用,由特定条件触发的操作，满足条件方才执行,否则不执行</li>
<li>tags 标签  指定某条任务执行,用于选择运行playbook中的部分代码。ansible具有幂等性,因此会自动跳过没有变化的部分，即便如此，有些代码为测试其确实没有发生变化的时间<br>依然会很长。因此可以使用tags跳过一些代码片段。<br>ansible-playbook -t tagsname useradd.yml</li>
</ul>
<p>adhoc 和 playbook 对比</p>
<pre><code class="bash"># adhoc 改变主机名字
ansible ho -m hostname -a &#39;name=xxx&#39;
# playboot 修改主机名字
---
- host: ho
  remote_user: root

  tasks:
  - name: hello
    hostname: name=node</code></pre>
<p>多条adhoc 和playbook对比</p>
<pre><code class="bash"># adhoc 
ansible ho -m file -a &#39;name=/data/newfile state=touch&#39;  # 创建文件
ansible ho -m user -a &#39;name=test2 system=yes shell=/sbin/nologin&#39; # 创建用户
ansible ho -m yum -a &#39;name=httpd&#39; # 安装httpd
ansible ho -m copy -a &#39;src=/var/www/html/index.html dest=/var/www/html&#39; # 复制文件
ansible ho -m service -a &#39;name=httpd state=started enabled=yes&#39; # 启动服务


# playbook
- hosts: ho
  remote_user: root

  tasks:
  - name: create file
    file: name=/data/newfile state=touch
  - name: create user
    file: name=test2 system=yes shell=/sbin/nologin
  - name: install httpd
    yum: name=httpd
  - name: copy file
    copy: src=/var/www/html/index.html dest=/var/www/html
  - name: start service
    service: name=httpd state=started enabled=yes</code></pre>
<p>shell脚本与playbook对比</p>
<pre><code class="bash"># shell脚本

#!/bin/bash
# 安装Apache
yum install --quiet -y httpd
# 复制配置文件
cp /tmp/httpd.conf /etc/httpd/conf/httpd.conf
cp /tmp/vhosts.conf /etc/httpd/conf.d/
# 启动Apache 并设置开机启动
systemctl start httpd.service
chkconfig httpd on

# playbook
---
- host: all
  tasks:
   - name: &quot;安装Apache&quot;
     yum: name=httpd
   - name: &quot;复制配置文件&quot;
     copy: src=/tmp/httpd.conf dest=/etc/httpd/conf/
   - name: &quot;复制文件&quot;
     copy: src=/tmp/vhosts.conf dest=/etc/httpd/conf.d/
   - name: &quot;启动Apache,并设置开机启动&quot;
     service: name=httpd state=started enabled=yes</code></pre>
<h3 id="执行流程"><a href="#执行流程" class="headerlink" title="执行流程"></a>执行流程</h3><p>play的主体部分是task list 。 task list 中的各任务按次序逐个在hosts中指定的所有主机上执行，即在所有主机上完成第一个任务后在开始第二个，在运行自上而下某一个playbook时，如果中途发生错误，所有已执行任务都将回滚，因此，在更正playbook后重新执行一次即可</p>
<p><strong>忽略错误信息</strong></p>
<pre><code class="bash">task:
- name: copy file
  copy: src=/root/file dest=/root/ || /bin/true

# 或者
task:
- name: copy file
  copy: src=/root/file dest=/root/
  ignore_erros: True</code></pre>
<h3 id="playbook运行方式"><a href="#playbook运行方式" class="headerlink" title="playbook运行方式"></a>playbook运行方式</h3><pre><code class="bash">ansible-playbook &lt;xxx.yml&gt; [options]
--check 只检测可能会发生的改变，但不真正执行操作
--list-hosts 列出运行任务的主机
--limit 主机列表 只针对主机列表中的主机执行
-v 显示过程 -vv -vvv显示更详细</code></pre>
<h3 id="Playbook剧本"><a href="#Playbook剧本" class="headerlink" title="Playbook剧本"></a>Playbook剧本</h3><p>ansible-playbook是ansible中的一个工具,存放在/usr/bin/ansible-playbook</p>
<h1 id="其他"><a href="#其他" class="headerlink" title="其他"></a>其他</h1><ul>
<li><p>模块<br><a href="https://www.cnblogs.com/f-ck-need-u/p/7550603.html" target="_blank" rel="noopener">https://www.cnblogs.com/f-ck-need-u/p/7550603.html</a><br><a href="https://docs.ansible.com/ansible/2.6/modules/list_of_all_modules.html" target="_blank" rel="noopener">https://docs.ansible.com/ansible/2.6/modules/list_of_all_modules.html</a></p>
</li>
<li><p>ansible模块开发<br><a href="https://www.jianshu.com/p/f72b79b0d3f9" target="_blank" rel="noopener">https://www.jianshu.com/p/f72b79b0d3f9</a>  </p>
</li>
</ul>

        </div>
        
        
        
        
    </div>
</div>









    <div class="card">
    
    <div class="card-content article ">
        <h1 class="title is-size-3 is-size-4-mobile has-text-weight-normal">
            
                <a class="has-link-black-ter" href="/2019/12/29/blog_back_new/ansible/ansible%E6%89%B9%E9%87%8F%E6%8E%A7%E5%88%B6%E4%BA%A4%E6%8D%A2%E6%9C%BA/"><i class="fas fa-angle-double-right"></i>ansible总结</a>
            
        </h1>
        
        <div class="level article-meta is-size-7 is-uppercase is-mobile is-overflow-x-auto">
            <div class="level-left">
                <time class="level-item has-text-grey" datetime="2019-12-29T12:54:12.000Z"><i class="far fa-calendar-alt">&nbsp;</i>2019-12-29</time>
                
                <time class="level-item has-text-grey is-hidden-mobile" datetime="2019-12-29T12:56:13.070Z"><i class="far fa-calendar-check">&nbsp;</i>2019-12-29</time>
                
                
                <div class="level-item">
                <i class="far fa-folder-open has-text-grey"></i>&nbsp;
                <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a>&nbsp;/&nbsp;<a class="has-link-grey -link" href="/categories/blog-back-new/ansible/">ansible</a>
                </div>
                
                
                <span class="level-item has-text-grey">
                    <i class="far fa-clock"></i>&nbsp;
                    
                    
                    2 minutes read (About 233 words)
                </span>
                
                
            </div>
        </div>
        
        <div class="content">
            <h1 id="登陆h3c交换机"><a href="#登陆h3c交换机" class="headerlink" title="登陆h3c交换机"></a>登陆h3c交换机</h1><p>h3c交换机的模块支持度极低，网上大多都是思科交换机的模块，很多要用到H3c的都是自己写的，感觉很坑</p>
<h2 id="问题"><a href="#问题" class="headerlink" title="问题:"></a>问题:</h2><p>现在又一个问题就是命令行使用raw模块可以登陆交换机，并且输出执指令 返回结果，但是在ansible-playbook中不行</p>
<pre><code class="bash">echo &quot;10.0.5.124&quot;  &gt;&gt; ./xx
ansible -i xx all -m raw -a &#39;system-view ;dis arp ;&#39;</code></pre>
<p>如上是可以的，但是如下的playbook则不行</p>
<pre><code class="bash">echo first.yml &lt;&lt; EOF
  ---
  - hosts: switch

    tasks:
    - name: add snmp
      raw: &quot;system-view ;&quot;
EOF

ansible-playbook first.yml</code></pre>
<p>解决办法，既然playbook不行，那就切换成一条一条的命令行把</p>
<pre><code class="bash">echo yy &lt;&lt; EOF
system-view ;
display arp ;
EOF

echo &quot;10.0.5.124 ansible_ssh_user=admin ansible_ssh_pass=upyun123&quot; &gt;&gt; xx
while read cmd;do ansible -i xx -m raw -a &quot;$cmd&quot; -u an -k ;done &lt; yy</code></pre>
<h2 id="other"><a href="#other" class="headerlink" title="other"></a>other</h2><p>python+yaml+jinja2 自动生成华三交换机配置<br><a href="https://www.jianshu.com/p/4937de3070aa" target="_blank" rel="noopener">https://www.jianshu.com/p/4937de3070aa</a></p>

        </div>
        
        
        
        
    </div>
</div>










    
<div class="card card-transparent">
    <nav class="pagination is-centered" role="navigation" aria-label="pagination">
        <div class="pagination-previous is-invisible is-hidden-mobile">
            <a class="is-flex-grow has-text-black-ter" href="/page/0/">Previous</a>
        </div>
        <div class="pagination-next">
            <a class="is-flex-grow has-text-black-ter" href="/page/2/">Next</a>
        </div>
        <ul class="pagination-list is-hidden-mobile">
            
            <li><a class="pagination-link is-current" href="/">1</a></li>
            
            <li><a class="pagination-link has-text-black-ter" href="/page/2/">2</a></li>
            
            <li><a class="pagination-link has-text-black-ter" href="/page/3/">3</a></li>
            
            <li><a class="pagination-link has-text-black-ter" href="/page/4/">4</a></li>
            
        </ul>
    </nav>
</div>
</div>
                




<div class="column is-4-tablet is-4-desktop is-3-widescreen  has-order-1 column-left ">
    
        
<div class="card widget">
    <div class="card-content">
        <nav class="level" style="margin-bottom:1rem">
            <div class="level-item has-text-centered">
                <div>
                    
                        <img class="image is-96x96 has-mb-6" src="https://www.gravatar.com/avatar/e0f4032c0f2d1068ffffbaf93c0bef52?s=96" alt="Xinyu Liu">
                    
                    
                    <p class="is-size-4 is-block">
                        Xinyu Liu
                    </p>
                    
                    
                    <p class="is-size-6 is-block">
                        Alpha Lxy
                    </p>
                    
                    
                    <p class="is-size-6 is-flex is-flex-center has-text-grey">
                        <i class="fas fa-map-marker-alt has-mr-7"></i>
                        <span>Beijing, China</span>
                    </p>
                    
                </div>
            </div>
        </nav>
        <nav class="level menu-list is-mobile" style="margin-bottom:1rem">
            <div class="level-item has-text-centered is-marginless">
                <a href="/archives/">
                    <p class="heading">
                        Posts
                    </p>
                    <p class="title has-text-weight-normal">
                        40
                    </p>
                </a>
            </div>
            <div class="level-item has-text-centered is-marginless">
                <a href="/categories/">
                    <p class="heading">
                        Categories
                    </p>
                    <p class="title has-text-weight-normal">
                        13
                    </p>
                </a>
            </div>
            <div class="level-item has-text-centered is-marginless">
                <a href="/tags/">
                    <p class="heading">
                        Tags
                    </p>
                    <p class="title has-text-weight-normal">
                        0
                    </p>
                </a>
            </div>
        </nav>
        <div class="level">
            <a class="level-item button is-link is-rounded" href="https://www.github.com/AlphaLxy" target="_blank">
                <i class="fab fa-github"></i>&nbsp;&nbsp;Follow</a>
        </div>
        
        
    </div>
</div>

    
        

    
        


    
        

    
        <div class="card widget is-hidden-mobile">
    <div class="card-content">
        <div class="menu">
        <h3 class="menu-label">
            Archives
        </h3>
        <ul class="menu-list">
        
        <li>
            <a class="level is-marginless" href="/archives/2020/01/">
                <span class="level-start">
                    <span class="level-item">January 2020</span>
                </span>
                <span class="level-end">
                    <span class="level-item tag">8</span>
                </span>
            </a>
        </li>
        
        <li>
            <a class="level is-marginless" href="/archives/2019/12/">
                <span class="level-start">
                    <span class="level-item">December 2019</span>
                </span>
                <span class="level-end">
                    <span class="level-item tag">32</span>
                </span>
            </a>
        </li>
        
        </ul>
        </div>
    </div>
</div>

    
    
        <div class="column-right-shadow is-hidden-widescreen ">
        
            
<div class="card widget">
    <div class="card-content">
        <h3 class="menu-label">
            Recent
        </h3>
        
        <article class="media">
            
            <a href="/2020/01/05/blog_back_new/linux/keepalive+lvs%E5%9B%9B%E5%B1%82%E8%B4%9F%E8%BD%BD%E5%9D%87%E8%A1%A1/" class="media-left">
                <p class="image is-64x64">
                    <img class="thumbnail" src="/images/thumbnail.svg" alt="keepalive+lvs 四层负载均衡">
                </p>
            </a>
            
            <div class="media-content">
                <div class="content">
                    <div><time class="has-text-grey is-size-7 is-uppercase" datetime="2020-01-05T05:06:09.000Z">2020-01-05</time></div>
                    <a href="/2020/01/05/blog_back_new/linux/keepalive+lvs%E5%9B%9B%E5%B1%82%E8%B4%9F%E8%BD%BD%E5%9D%87%E8%A1%A1/" class="has-link-black-ter is-size-6">keepalive+lvs 四层负载均衡</a>
                    <p class="is-size-7 is-uppercase">
                        <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a> / <a class="has-link-grey -link" href="/categories/blog-back-new/linux/">linux</a>
                    </p>
                </div>
            </div>
        </article>
        
        <article class="media">
            
            <a href="/2020/01/05/blog_back_new/linux/linux%E7%BD%91%E7%BB%9C%E7%AE%A1%E7%90%86/iptables%E3%80%81firewall%E9%98%B2%E7%81%AB%E5%A2%99/" class="media-left">
                <p class="image is-64x64">
                    <img class="thumbnail" src="/images/thumbnail.svg" alt="iptables、firewall 防火墙">
                </p>
            </a>
            
            <div class="media-content">
                <div class="content">
                    <div><time class="has-text-grey is-size-7 is-uppercase" datetime="2020-01-05T04:03:16.000Z">2020-01-05</time></div>
                    <a href="/2020/01/05/blog_back_new/linux/linux%E7%BD%91%E7%BB%9C%E7%AE%A1%E7%90%86/iptables%E3%80%81firewall%E9%98%B2%E7%81%AB%E5%A2%99/" class="has-link-black-ter is-size-6">iptables、firewall 防火墙</a>
                    <p class="is-size-7 is-uppercase">
                        <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a> / <a class="has-link-grey -link" href="/categories/blog-back-new/linux/">linux</a>
                    </p>
                </div>
            </div>
        </article>
        
        <article class="media">
            
            <a href="/2020/01/05/blog_back_new/linux/linux%E7%BD%91%E7%BB%9C%E7%AE%A1%E7%90%86/netstat/" class="media-left">
                <p class="image is-64x64">
                    <img class="thumbnail" src="/images/thumbnail.svg" alt="netstat">
                </p>
            </a>
            
            <div class="media-content">
                <div class="content">
                    <div><time class="has-text-grey is-size-7 is-uppercase" datetime="2020-01-05T03:51:48.000Z">2020-01-05</time></div>
                    <a href="/2020/01/05/blog_back_new/linux/linux%E7%BD%91%E7%BB%9C%E7%AE%A1%E7%90%86/netstat/" class="has-link-black-ter is-size-6">netstat</a>
                    <p class="is-size-7 is-uppercase">
                        <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a> / <a class="has-link-grey -link" href="/categories/blog-back-new/linux/">linux</a>
                    </p>
                </div>
            </div>
        </article>
        
        <article class="media">
            
            <a href="/2020/01/04/blog_back_new/%E7%BD%91%E7%BB%9C/%E7%BD%91%E7%BB%9C%E9%83%A8%E7%BD%B2%E9%9C%80%E6%B1%82%E5%88%86%E6%9E%90/" class="media-left">
                <p class="image is-64x64">
                    <img class="thumbnail" src="/images/thumbnail.svg" alt="网络部署需求分析">
                </p>
            </a>
            
            <div class="media-content">
                <div class="content">
                    <div><time class="has-text-grey is-size-7 is-uppercase" datetime="2020-01-04T02:22:09.000Z">2020-01-04</time></div>
                    <a href="/2020/01/04/blog_back_new/%E7%BD%91%E7%BB%9C/%E7%BD%91%E7%BB%9C%E9%83%A8%E7%BD%B2%E9%9C%80%E6%B1%82%E5%88%86%E6%9E%90/" class="has-link-black-ter is-size-6">网络部署需求分析</a>
                    <p class="is-size-7 is-uppercase">
                        <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a> / <a class="has-link-grey -link" href="/categories/blog-back-new/%E7%BD%91%E7%BB%9C/">网络</a>
                    </p>
                </div>
            </div>
        </article>
        
        <article class="media">
            
            <a href="/2020/01/03/blog_back_new/linux/httpd%E6%9C%8D%E5%8A%A1/" class="media-left">
                <p class="image is-64x64">
                    <img class="thumbnail" src="/images/thumbnail.svg" alt="httpd服务">
                </p>
            </a>
            
            <div class="media-content">
                <div class="content">
                    <div><time class="has-text-grey is-size-7 is-uppercase" datetime="2020-01-03T09:18:50.000Z">2020-01-03</time></div>
                    <a href="/2020/01/03/blog_back_new/linux/httpd%E6%9C%8D%E5%8A%A1/" class="has-link-black-ter is-size-6">httpd服务</a>
                    <p class="is-size-7 is-uppercase">
                        <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a> / <a class="has-link-grey -link" href="/categories/blog-back-new/linux/">linux</a>
                    </p>
                </div>
            </div>
        </article>
        
    </div>
</div>

        
            
<div class="card widget">
    <div class="card-content">
        <div class="menu">
            <h3 class="menu-label">
                Categories
            </h3>
            <ul class="menu-list">
            <li>
        <a class="level is-marginless" href="/categories/blog-back-new/">
            <span class="level-start">
                <span class="level-item">blog_back_new</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">39</span>
            </span>
        </a><ul><li>
        <a class="level is-marginless" href="/categories/blog-back-new/C%E8%AF%AD%E8%A8%80/">
            <span class="level-start">
                <span class="level-item">C语言</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">1</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/Python/">
            <span class="level-start">
                <span class="level-item">Python</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">4</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/Rust/">
            <span class="level-start">
                <span class="level-item">Rust</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">5</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/ansible/">
            <span class="level-start">
                <span class="level-item">ansible</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">2</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/django/">
            <span class="level-start">
                <span class="level-item">django</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">8</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/git/">
            <span class="level-start">
                <span class="level-item">git</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">1</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/linux/">
            <span class="level-start">
                <span class="level-item">linux</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">4</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/mysql/">
            <span class="level-start">
                <span class="level-item">mysql</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">1</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/%E6%89%A9%E5%B1%95/">
            <span class="level-start">
                <span class="level-item">扩展</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">3</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/">
            <span class="level-start">
                <span class="level-item">数据结构</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">1</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/%E7%BD%91%E7%BB%9C/">
            <span class="level-start">
                <span class="level-item">网络</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">3</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/%E8%AE%BE%E5%A4%87/">
            <span class="level-start">
                <span class="level-item">设备</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">6</span>
            </span>
        </a></li></ul></li>
            </ul>
        </div>
    </div>
</div>
        
        </div>
    
</div>

                




<div class="column is-4-tablet is-4-desktop is-3-widescreen is-hidden-touch is-hidden-desktop-only has-order-3 column-right ">
    
        
<div class="card widget">
    <div class="card-content">
        <h3 class="menu-label">
            Recent
        </h3>
        
        <article class="media">
            
            <a href="/2020/01/05/blog_back_new/linux/keepalive+lvs%E5%9B%9B%E5%B1%82%E8%B4%9F%E8%BD%BD%E5%9D%87%E8%A1%A1/" class="media-left">
                <p class="image is-64x64">
                    <img class="thumbnail" src="/images/thumbnail.svg" alt="keepalive+lvs 四层负载均衡">
                </p>
            </a>
            
            <div class="media-content">
                <div class="content">
                    <div><time class="has-text-grey is-size-7 is-uppercase" datetime="2020-01-05T05:06:09.000Z">2020-01-05</time></div>
                    <a href="/2020/01/05/blog_back_new/linux/keepalive+lvs%E5%9B%9B%E5%B1%82%E8%B4%9F%E8%BD%BD%E5%9D%87%E8%A1%A1/" class="has-link-black-ter is-size-6">keepalive+lvs 四层负载均衡</a>
                    <p class="is-size-7 is-uppercase">
                        <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a> / <a class="has-link-grey -link" href="/categories/blog-back-new/linux/">linux</a>
                    </p>
                </div>
            </div>
        </article>
        
        <article class="media">
            
            <a href="/2020/01/05/blog_back_new/linux/linux%E7%BD%91%E7%BB%9C%E7%AE%A1%E7%90%86/iptables%E3%80%81firewall%E9%98%B2%E7%81%AB%E5%A2%99/" class="media-left">
                <p class="image is-64x64">
                    <img class="thumbnail" src="/images/thumbnail.svg" alt="iptables、firewall 防火墙">
                </p>
            </a>
            
            <div class="media-content">
                <div class="content">
                    <div><time class="has-text-grey is-size-7 is-uppercase" datetime="2020-01-05T04:03:16.000Z">2020-01-05</time></div>
                    <a href="/2020/01/05/blog_back_new/linux/linux%E7%BD%91%E7%BB%9C%E7%AE%A1%E7%90%86/iptables%E3%80%81firewall%E9%98%B2%E7%81%AB%E5%A2%99/" class="has-link-black-ter is-size-6">iptables、firewall 防火墙</a>
                    <p class="is-size-7 is-uppercase">
                        <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a> / <a class="has-link-grey -link" href="/categories/blog-back-new/linux/">linux</a>
                    </p>
                </div>
            </div>
        </article>
        
        <article class="media">
            
            <a href="/2020/01/05/blog_back_new/linux/linux%E7%BD%91%E7%BB%9C%E7%AE%A1%E7%90%86/netstat/" class="media-left">
                <p class="image is-64x64">
                    <img class="thumbnail" src="/images/thumbnail.svg" alt="netstat">
                </p>
            </a>
            
            <div class="media-content">
                <div class="content">
                    <div><time class="has-text-grey is-size-7 is-uppercase" datetime="2020-01-05T03:51:48.000Z">2020-01-05</time></div>
                    <a href="/2020/01/05/blog_back_new/linux/linux%E7%BD%91%E7%BB%9C%E7%AE%A1%E7%90%86/netstat/" class="has-link-black-ter is-size-6">netstat</a>
                    <p class="is-size-7 is-uppercase">
                        <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a> / <a class="has-link-grey -link" href="/categories/blog-back-new/linux/">linux</a>
                    </p>
                </div>
            </div>
        </article>
        
        <article class="media">
            
            <a href="/2020/01/04/blog_back_new/%E7%BD%91%E7%BB%9C/%E7%BD%91%E7%BB%9C%E9%83%A8%E7%BD%B2%E9%9C%80%E6%B1%82%E5%88%86%E6%9E%90/" class="media-left">
                <p class="image is-64x64">
                    <img class="thumbnail" src="/images/thumbnail.svg" alt="网络部署需求分析">
                </p>
            </a>
            
            <div class="media-content">
                <div class="content">
                    <div><time class="has-text-grey is-size-7 is-uppercase" datetime="2020-01-04T02:22:09.000Z">2020-01-04</time></div>
                    <a href="/2020/01/04/blog_back_new/%E7%BD%91%E7%BB%9C/%E7%BD%91%E7%BB%9C%E9%83%A8%E7%BD%B2%E9%9C%80%E6%B1%82%E5%88%86%E6%9E%90/" class="has-link-black-ter is-size-6">网络部署需求分析</a>
                    <p class="is-size-7 is-uppercase">
                        <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a> / <a class="has-link-grey -link" href="/categories/blog-back-new/%E7%BD%91%E7%BB%9C/">网络</a>
                    </p>
                </div>
            </div>
        </article>
        
        <article class="media">
            
            <a href="/2020/01/03/blog_back_new/linux/httpd%E6%9C%8D%E5%8A%A1/" class="media-left">
                <p class="image is-64x64">
                    <img class="thumbnail" src="/images/thumbnail.svg" alt="httpd服务">
                </p>
            </a>
            
            <div class="media-content">
                <div class="content">
                    <div><time class="has-text-grey is-size-7 is-uppercase" datetime="2020-01-03T09:18:50.000Z">2020-01-03</time></div>
                    <a href="/2020/01/03/blog_back_new/linux/httpd%E6%9C%8D%E5%8A%A1/" class="has-link-black-ter is-size-6">httpd服务</a>
                    <p class="is-size-7 is-uppercase">
                        <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a> / <a class="has-link-grey -link" href="/categories/blog-back-new/linux/">linux</a>
                    </p>
                </div>
            </div>
        </article>
        
    </div>
</div>

    
        
<div class="card widget">
    <div class="card-content">
        <div class="menu">
            <h3 class="menu-label">
                Categories
            </h3>
            <ul class="menu-list">
            <li>
        <a class="level is-marginless" href="/categories/blog-back-new/">
            <span class="level-start">
                <span class="level-item">blog_back_new</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">39</span>
            </span>
        </a><ul><li>
        <a class="level is-marginless" href="/categories/blog-back-new/C%E8%AF%AD%E8%A8%80/">
            <span class="level-start">
                <span class="level-item">C语言</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">1</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/Python/">
            <span class="level-start">
                <span class="level-item">Python</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">4</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/Rust/">
            <span class="level-start">
                <span class="level-item">Rust</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">5</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/ansible/">
            <span class="level-start">
                <span class="level-item">ansible</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">2</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/django/">
            <span class="level-start">
                <span class="level-item">django</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">8</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/git/">
            <span class="level-start">
                <span class="level-item">git</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">1</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/linux/">
            <span class="level-start">
                <span class="level-item">linux</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">4</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/mysql/">
            <span class="level-start">
                <span class="level-item">mysql</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">1</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/%E6%89%A9%E5%B1%95/">
            <span class="level-start">
                <span class="level-item">扩展</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">3</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/">
            <span class="level-start">
                <span class="level-item">数据结构</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">1</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/%E7%BD%91%E7%BB%9C/">
            <span class="level-start">
                <span class="level-item">网络</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">3</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/%E8%AE%BE%E5%A4%87/">
            <span class="level-start">
                <span class="level-item">设备</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">6</span>
            </span>
        </a></li></ul></li>
            </ul>
        </div>
    </div>
</div>
    
    
</div>

            </div>
        </div>
    </section>
    <footer class="footer">
    <div class="container">
        <div class="level">
            <div class="level-start has-text-centered-mobile">
                <a class="footer-logo is-block has-mb-6" href="/">
                
                    <img src="/images/logo.svg" alt="noback" height="28">
                
                </a>
                <p class="is-size-7">
                &copy; 2020 Alpaca&nbsp;
                Powered by <a href="http://hexo.io/" target="_blank">Hexo</a> & <a
                        href="http://github.com/ppoffice/hexo-theme-icarus" target="_blank">Icarus</a>
                
                <br>
                <span id="busuanzi_container_site_uv">
                Visited by <span id="busuanzi_value_site_uv">0</span> users
                </span>
                
                </p>
            </div>
            <div class="level-end">
            
                <div class="field has-addons is-flex-center-mobile has-mt-5-mobile is-flex-wrap is-flex-middle">
                
                
                <p class="control">
                    <a class="button is-white is-large" target="_blank" title="CC BY-NC-SA 4.0" href="https://creativecommons.org/licenses/by-nc-sa/4.0/">
                        
                        <i class="fab fa-creative-commons"></i>&nbsp;<i class="fab fa-creative-commons-by"></i>&nbsp;<i class="fab fa-creative-commons-nc"></i>&nbsp;<i class="fab fa-creative-commons-sa"></i>&nbsp;
                        
                    </a>
                </p>
                
                <p class="control">
                    <a class="button is-white is-large" target="_blank" title="AlphaLxy GitHub" href="https://www.github.com/AlphaLxy">
                        
                        <i class="fab fa-github"></i>&nbsp;
                        
                    </a>
                </p>
                
                </div>
            
            </div>
        </div>
    </div>
</footer>

    <script src="https://cdn.jsdelivr.net/npm/jquery@3.3.1/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/moment@2.22.2/min/moment-with-locales.min.js"></script>
<script>moment.locale("en");</script>


    
    
    
    <script src="/js/animation.js"></script>
    

    
    
    
    <script src="https://cdn.jsdelivr.net/npm/lightgallery@1.6.8/dist/js/lightgallery.min.js" defer></script>
    <script src="https://cdn.jsdelivr.net/npm/justifiedGallery@3.7.0/dist/js/jquery.justifiedGallery.min.js" defer></script>
    <script src="/js/gallery.js" defer></script>
    

    
    

<div id="outdated">
    <h6>Your browser is out-of-date!</h6>
    <p>Update your browser to view this website correctly. <a id="btnUpdateBrowser" href="http://outdatedbrowser.com/" target="_blank" rel="noopener">Update
            my browser now </a></p>
    <p class="last"><a href="#" id="btnCloseUpdateBrowser" title="Close">&times;</a></p>
</div>
<script src="https://cdn.jsdelivr.net/npm/outdatedbrowser@1.1.5/outdatedbrowser/outdatedbrowser.min.js" defer></script>
<script>
    document.addEventListener("DOMContentLoaded", function () {
        outdatedBrowser({
            bgColor: '#f25648',
            color: '#ffffff',
            lowerThan: 'flex'
        });
    });
</script>


    
    
<script src="https://cdn.jsdelivr.net/npm/mathjax@2.7.5/unpacked/MathJax.js?config=TeX-MML-AM_CHTML" defer></script>
<script>
document.addEventListener('DOMContentLoaded', function () {
    MathJax.Hub.Config({
        'HTML-CSS': {
            matchFontHeight: false
        },
        SVG: {
            matchFontHeight: false
        },
        CommonHTML: {
            matchFontHeight: false
        },
        tex2jax: {
            inlineMath: [
                ['$','$'],
                ['\\(','\\)']
            ]
        }
    });
});
</script>

    
    

<a id="back-to-top" title="Back to Top" href="javascript:;">
    <i class="fas fa-chevron-up"></i>
</a>
<script src="/js/back-to-top.js" defer></script>


    
    

    
    
    
    

    
    
    
    
    
    <script src="https://cdn.jsdelivr.net/npm/clipboard@2.0.4/dist/clipboard.min.js" defer></script>
    <script src="/js/clipboard.js" defer></script>
    

    
    
    

    


<script src="/js/main.js" defer></script>

    
    <div class="searchbox ins-search">
    <div class="searchbox-container ins-search-container">
        <div class="searchbox-input-wrapper">
            <input type="text" class="searchbox-input ins-search-input" placeholder="Type something..." />
            <span class="searchbox-close ins-close ins-selectable"><i class="fa fa-times-circle"></i></span>
        </div>
        <div class="searchbox-result-wrapper ins-section-wrapper">
            <div class="ins-section-container"></div>
        </div>
    </div>
</div>
<script>
    (function (window) {
        var INSIGHT_CONFIG = {
            TRANSLATION: {
                POSTS: 'Posts',
                PAGES: 'Pages',
                CATEGORIES: 'Categories',
                TAGS: 'Tags',
                UNTITLED: '(Untitled)',
            },
            CONTENT_URL: '/content.json',
        };
        window.INSIGHT_CONFIG = INSIGHT_CONFIG;
    })(window);
</script>
<script src="/js/insight.js" defer></script>
<link rel="stylesheet" href="/css/search.css">
<link rel="stylesheet" href="/css/insight.css">
    
</body>
</html>